Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Last active August 29, 2015 13:57
Show Gist options
  • Save springmeyer/0a4e06bdec994db751b2 to your computer and use it in GitHub Desktop.
Save springmeyer/0a4e06bdec994db751b2 to your computer and use it in GitHub Desktop.

Followup to aws/aws-sdk-js#158 (comment)

Setup

npm install

Running tests

The test.js hangs for me on OS X with node v0.10.26 - should it?

$ node test.js # process never exits

The test2.js replicates a situation where an error is throw inside the callback passed to s3.putObject and the outcome, oddly, is that the callback is called 290 times in succession:

$ node test2.js 
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [200: null]
  message: null,
  code: 200,
  time: Mon Mar 17 2014 15:23:29 GMT-0700 (PDT),
  statusCode: 200,
  retryable: false,
  _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [200: null]
  message: null,
  code: 200,
  time: Mon Mar 17 2014 15:23:29 GMT-0700 (PDT),
  statusCode: 200,
  retryable: false,
  _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
{ [Error: here] statusCode: 200, retryable: false, _willRetry: false }
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
[Error: here]
290

Error: here
    at Response.<anonymous> (/Users/dane/aws-testcase/0a4e06bdec994db751b2/test2.js:14:11)
    at Request.<anonymous> (/Users/dane/aws-testcase/0a4e06bdec994db751b2/node_modules/aws-sdk/lib/request.js:331:20)
    at Request.callListeners (/Users/dane/aws-testcase/0a4e06bdec994db751b2/node_modules/aws-sdk/lib/sequential_executor.js:113:20)
    at Request.emit (/Users/dane/aws-testcase/0a4e06bdec994db751b2/node_modules/aws-sdk/lib/sequential_executor.js:81:10)
    at Request.emit (/Users/dane/aws-testcase/0a4e06bdec994db751b2/node_modules/aws-sdk/lib/request.js:557:14)
    at Request.transition (/Users/dane/aws-testcase/0a4e06bdec994db751b2/node_modules/aws-sdk/lib/request.js:12:12)
    at AcceptorStateMachine.runTo (/Users/dane/aws-testcase/0a4e06bdec994db751b2/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/dane/aws-testcase/0a4e06bdec994db751b2/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.transition (/Users/dane/aws-testcase/0a4e06bdec994db751b2/node_modules/aws-sdk/lib/request.js:26:7)
    at AcceptorStateMachine.runTo (/Users/dane/aws-testcase/0a4e06bdec994db751b2/node_modules/aws-sdk/lib/state_machine.js:14:12)
{
"name" : "aws-sdk-test",
"main" : "./test.js",
"dependencies" : {
"aws-sdk":"2.0.0-rc11"
}
}
var AWS = require("aws-sdk");
// note: AMAZON_ACCESS_KEY_ID and AMAZON_SECRET_ACCESS_KEY are set in environment
var s3 = new AWS.S3();
var s3_obj_opts = { Body: new Buffer(0),
Bucket: 'node-pre-gyp-tests',
Key: 'test.tar.gz',
};
s3.putObject(s3_obj_opts, function(err, resp){
console.log('never called');
});
var AWS = require("aws-sdk");
// note: AMAZON_ACCESS_KEY_ID and AMAZON_SECRET_ACCESS_KEY are set in environment
var s3 = new AWS.S3();
var s3_obj_opts = { Body: new Buffer(1),
Bucket: 'node-pre-gyp-tests',
Key: 'test.tar.gz',
};
var count = 0;
s3.putObject(s3_obj_opts, function(err, resp){
if (err) console.log(err);
count++;
throw new Error('here'); // this unhandled error leads the callback to be called 290 times
});
process.on('exit',function() {
console.log(count)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment