2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2012-07-16 16:38:11 -07:00
|
|
|
// Make sure that the domain stack doesn't get out of hand.
|
|
|
|
|
2015-12-23 16:02:12 -08:00
|
|
|
require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const domain = require('domain');
|
2012-07-16 16:38:11 -07:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const a = domain.create();
|
2012-07-16 16:38:11 -07:00
|
|
|
a.name = 'a';
|
|
|
|
|
|
|
|
a.on('error', function() {
|
|
|
|
if (domain._stack.length > 5) {
|
|
|
|
console.error('leaking!', domain._stack);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const foo = a.bind(function() {
|
2012-07-16 16:38:11 -07:00
|
|
|
throw new Error('error from foo');
|
|
|
|
});
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
for (let i = 0; i < 1000; i++) {
|
2012-07-16 16:38:11 -07:00
|
|
|
process.nextTick(foo);
|
|
|
|
}
|
2012-07-17 08:17:34 -07:00
|
|
|
|
|
|
|
process.on('exit', function(c) {
|
|
|
|
if (!c) console.log('ok');
|
|
|
|
});
|