2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2015-12-23 16:02:12 -08:00
|
|
|
require('../common');
|
2012-08-11 18:31:44 -04:00
|
|
|
var domain = require('domain');
|
|
|
|
var assert = require('assert');
|
|
|
|
|
|
|
|
var timeout_err, timeout, immediate_err;
|
|
|
|
|
|
|
|
var timeoutd = domain.create();
|
|
|
|
|
|
|
|
timeoutd.on('error', function(e) {
|
|
|
|
timeout_err = e;
|
|
|
|
clearTimeout(timeout);
|
|
|
|
});
|
|
|
|
|
|
|
|
timeoutd.run(function() {
|
|
|
|
setTimeout(function() {
|
|
|
|
throw new Error('Timeout UNREFd');
|
|
|
|
}).unref();
|
|
|
|
});
|
|
|
|
|
|
|
|
var immediated = domain.create();
|
|
|
|
|
|
|
|
immediated.on('error', function(e) {
|
|
|
|
immediate_err = e;
|
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
timeout = setTimeout(function() {}, 10 * 1000);
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
|
|
|
assert.equal(timeout_err.message, 'Timeout UNREFd',
|
2016-04-25 23:32:35 -07:00
|
|
|
'Domain should catch timer error');
|
2012-08-11 18:31:44 -04:00
|
|
|
assert.equal(immediate_err.message, 'Immediate Error',
|
2016-04-25 23:32:35 -07:00
|
|
|
'Domain should catch immediate error');
|
2012-08-11 18:31:44 -04:00
|
|
|
});
|