Skip to content

Instantly share code, notes, and snippets.

@bengl
Last active December 10, 2015 23:08
Show Gist options
  • Save bengl/4507125 to your computer and use it in GitHub Desktop.
Save bengl/4507125 to your computer and use it in GitHub Desktop.
domains don't really catch exceptions?
// node >= 0.8.*
var domain = require('domain');
process.on('uncaughtException', function(error){
console.error('UNCAUGHT!', error);
});
var d = domain.create();
d.on('error', function(error) {
console.error('CAUGHT!', error);
});
d.run(function(){
process.nextTick(function(){
throw Error('This is an error.');
})
});
/* OUTPUT:
CAUGHT! { [Error: This is an error.]
domain_thrown: true,
domain:
{ domain: null,
_events: { error: [Function] },
_maxListeners: 10,
members: [] } }
UNCAUGHT! { [Error: This is an error.]
domain_thrown: true,
domain:
{ domain: null,
_events: { error: [Function] },
_maxListeners: 10,
members: [] } }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment