2017-01-03 13:16:48 -08:00
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the
|
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
|
// following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
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) {
|
2018-04-14 19:30:17 +05:30
|
|
|
assert.strictEqual(e.message, 'Timeout UNREFd');
|
2018-01-29 14:52:01 -05:00
|
|
|
}, 2));
|
2012-08-11 18:31:44 -04:00
|
|
|
|
2018-01-29 14:52:01 -05:00
|
|
|
let t;
|
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();
|
2018-01-29 14:52:01 -05:00
|
|
|
|
|
|
|
t = setTimeout(function() {
|
2018-05-29 23:02:25 +02:00
|
|
|
clearTimeout(timeout);
|
2018-01-29 14:52:01 -05:00
|
|
|
throw new Error('Timeout UNREFd');
|
|
|
|
}, 0);
|
2012-08-11 18:31:44 -04:00
|
|
|
});
|
2018-01-29 14:52:01 -05:00
|
|
|
t.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) {
|
2018-04-14 19:30:17 +05:30
|
|
|
assert.strictEqual(e.message, '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-06-05 11:22:26 -07:00
|
|
|
const timeout = setTimeout(common.mustNotCall(), 10 * 1000);
|