Skip to content

Instantly share code, notes, and snippets.

@russellhaering
Created January 16, 2012 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russellhaering/1623151 to your computer and use it in GitHub Desktop.
Save russellhaering/1623151 to your computer and use it in GitHub Desktop.
double callback introduced to node in 07c27e040eb41a1f564f1d92dbe1ad07b78f3a4e
var https = require('https');
function main() {
var fired = 0, req;
req = https.request({
host: 'localhost',
port: 8052,
path: '/',
method: 'GET'
});
req.on('error', function(err) {
fired++;
console.log('error callback fired: ' + err.toString());
});
setTimeout(function() {
if (fired !== 1) {
console.error('multiple error callbacks: ' + fired);
} else {
console.log('1 error callback, good!');
}
}, 5000);
req.end();
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment