-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node,timers: fix beforeExit with unrefed timers #2795
Changes from 3 commits
737d9b6
01df246
85854e0
baaaabf
c358723
5d7262c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
var once = 0; | ||
|
||
process.on('beforeExit', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why ignoring if the process fails? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not. But if the process has already failed we want that error, not the assertion. |
||
|
||
assert.strictEqual(once, 1); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trevnorris would it better for me to inline the
HasUnrefedTimerHandles(env)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naw. looks good as it is.