2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-07-15 15:43:24 -04:00
|
|
|
const common = require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const domain = require('domain');
|
|
|
|
const assert = require('assert');
|
2012-08-11 18:31:44 -04:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const timeoutd = domain.create();
|
2012-08-11 18:31:44 -04:00
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
timeoutd.on('error', common.mustCall(function(e) {
|
2016-12-01 10:38:53 -06:00
|
|
|
assert.strictEqual(e.message, 'Timeout UNREFd',
|
|
|
|
'Domain should catch timer error');
|
2012-08-11 18:31:44 -04:00
|
|
|
clearTimeout(timeout);
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
2012-08-11 18:31:44 -04:00
|
|
|
|
|
|
|
timeoutd.run(function() {
|
|
|
|
setTimeout(function() {
|
|
|
|
throw new Error('Timeout UNREFd');
|
2016-12-01 10:38:53 -06:00
|
|
|
}, 0).unref();
|
2012-08-11 18:31:44 -04:00
|
|
|
});
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const immediated = domain.create();
|
2012-08-11 18:31:44 -04:00
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
immediated.on('error', common.mustCall(function(e) {
|
2016-12-01 10:38:53 -06:00
|
|
|
assert.strictEqual(e.message, 'Immediate Error',
|
|
|
|
'Domain should catch immediate error');
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
2012-08-11 18:31:44 -04:00
|
|
|
|
|
|
|
immediated.run(function() {
|
2012-08-17 13:44:25 +02:00
|
|
|
setImmediate(function() {
|
2012-08-11 18:31:44 -04:00
|
|
|
throw new Error('Immediate Error');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const timeout = setTimeout(function() {}, 10 * 1000);
|