mirror of https://github.com/lukechilds/node.git
Browse Source
PR-URL: https://github.com/nodejs/node/pull/14616 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com>v6
8 changed files with 68 additions and 131 deletions
@ -1,27 +1,14 @@ |
|||
'use strict'; |
|||
require('../common'); |
|||
const assert = require('assert'); |
|||
const common = require('../common'); |
|||
|
|||
let called = 0; |
|||
let closed = 0; |
|||
|
|||
const timeout = setTimeout(function() { |
|||
called++; |
|||
}, 10); |
|||
const timeout = setTimeout(common.mustCall(), 10); |
|||
timeout.unref(); |
|||
|
|||
// Wrap `close` method to check if the handle was closed
|
|||
const close = timeout._handle.close; |
|||
timeout._handle.close = function() { |
|||
closed++; |
|||
timeout._handle.close = common.mustCall(function() { |
|||
return close.apply(this, arguments); |
|||
}; |
|||
}); |
|||
|
|||
// Just to keep process alive and let previous timer's handle die
|
|||
setTimeout(function() { |
|||
}, 50); |
|||
|
|||
process.on('exit', function() { |
|||
assert.strictEqual(called, 1); |
|||
assert.strictEqual(closed, 1); |
|||
}); |
|||
setTimeout(() => {}, 50); |
|||
|
@ -1,20 +1,7 @@ |
|||
'use strict'; |
|||
|
|||
require('../common'); |
|||
const assert = require('assert'); |
|||
const common = require('../common'); |
|||
|
|||
let once = 0; |
|||
|
|||
process.on('beforeExit', () => { |
|||
if (once > 1) |
|||
throw new RangeError('beforeExit should only have been called once!'); |
|||
|
|||
setTimeout(() => {}, 1).unref(); |
|||
once++; |
|||
}); |
|||
|
|||
process.on('exit', (code) => { |
|||
if (code !== 0) return; |
|||
|
|||
assert.strictEqual(once, 1); |
|||
}); |
|||
process.on('beforeExit', common.mustCall(() => { |
|||
setTimeout(common.mustNotCall(), 1).unref(); |
|||
})); |
|||
|
Loading…
Reference in new issue