Skip to content

Instantly share code, notes, and snippets.

@raoulmillais
Created May 21, 2014 16:50
Show Gist options
  • Save raoulmillais/eff16aa9967100dc3283 to your computer and use it in GitHub Desktop.
Save raoulmillais/eff16aa9967100dc3283 to your computer and use it in GitHub Desktop.
Nested domains rethrowing errors to outer domain
var domain = require('domain');
var d = domain.create();
d.on('error', function (err) {
console.log('Outer');
console.log(err);
});
d.run(function () {
var d2 = domain.create();
var outer = process.domain;
d2.on('error', function (err) {
console.log('Inner');
console.log(err);
outer.run(function () {
throw err;
});
});
d2.run(function () {
process.nextTick(function () {
throw new Error('I did a bad');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment