-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #14616 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
- Loading branch information
Showing
8 changed files
with
68 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters