nodejs/test/parallel/test-domain-stack.js

28 lines
512 B
JavaScript
Raw Normal View History

'use strict';
2012-07-16 16:38:11 -07:00
// Make sure that the domain stack doesn't get out of hand.
require('../common');
const domain = require('domain');
2012-07-16 16:38:11 -07: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);
}
});
const foo = a.bind(function() {
2012-07-16 16:38:11 -07:00
throw new Error('error from foo');
});
for (let i = 0; i < 1000; i++) {
2012-07-16 16:38:11 -07:00
process.nextTick(foo);
}
process.on('exit', function(c) {
if (!c) console.log('ok');
});