Skip to content

Instantly share code, notes, and snippets.

@shigeki
Created July 4, 2012 14:00
Show Gist options
  • Save shigeki/3047504 to your computer and use it in GitHub Desktop.
Save shigeki/3047504 to your computer and use it in GitHub Desktop.
Domain Stack Sample #4
// domain stack sample #3
var domain = require('domain');
var d1 = domain.create();
var d2 = domain.create();
var d3 = domain.create();
d1.on('error', function(err) {
console.log('d1:', err.message);
});
d2.on('error', function(err) {
console.log('d2:', err.message);
});
d3.on('error', function(err) {
console.log('d3:', err.message);
});
var arg = +process.argv[2];
var a = null;
d1.enter();
if(arg === 1) {
a.hoge;
}
d2.enter();
if (arg == 2) {
a.hoge;
}
d3.enter();
if (arg == 3) {
a.hoge;
}
> node domain_stack4.js 1
d1: Cannot read property 'hoge' of null
> node domain_stack4.js 2
d2: Cannot read property 'hoge' of null
> node domain_stack4.js 3
d3: Cannot read property 'hoge' of null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment