Created
March 3, 2014 21:28
-
-
Save iarna/9334983 to your computer and use it in GitHub Desktop.
Error domain bug in Node 0.10 (seems fixed in 0.11)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var soon = process.nextTick; | |
require('domain').create() | |
.on('error', function(E){ console.log("All is well soon") }) | |
.run(function() { | |
soon(function(){ throw new Error() }) | |
}); | |
// We expect "All is well soon" to be logged | |
// Instead we get: | |
/* | |
fail1.js:6 | |
soon(function(){ throw new Error() }) | |
^ | |
Error | |
at fail1.js:6:32 | |
at process._tickDomainCallback (node.js:459:13) | |
at Function.Module.runMain (module.js:499:11) | |
at startup (node.js:119:16) | |
at node.js:902:3 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('domain').create() | |
.on('error', function(E){ console.log("This shouldn't be called") }) | |
.run(function() { }); | |
var soon = process.nextTick; | |
require('domain').create() | |
.on('error', function(E){ console.log("All is well soon") }) | |
.run(function() { | |
soon(function(){ throw new Error() }) | |
}); | |
// We expect and get "All is well soon" | |
// Note that the only difference between this and fail1 is the empty failure domain at the top |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('domain').create() | |
.on('error', function(E){ console.log("All is well nextTick") }) | |
.run(function() { | |
process.nextTick(function(){ throw new Error() }) | |
}); | |
// We expect and get "all is well nextTick" logged |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nodejs/node-v0.x-archive#7231