Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
net: fix ambiguity in EOF handling#9066
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
indutny commented Oct 12, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
mcollina commented Oct 12, 2016
Nice one. I imagine there is very little chance to write a unit test for this, right? if not, LGTM. |
indutny commented Oct 12, 2016
@mcollina I actually just got an idea on how to do this, but wanted to gather some preliminary feedback first. |
indutny commented Oct 12, 2016
Added test. |
Trott commented Oct 12, 2016
@indutny Test not showing up here... (Forgot to push maybe? Or need to force-push maybe?) |
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first.
9920f17 to 6e38e76Compareindutny commented Oct 12, 2016
@Trott sorry, just pushed it! |
indutny commented Oct 12, 2016
Trott commented Oct 12, 2016
Stress test to make sure there's no unexpected flakiness hidden in the test somewhere: https://ci.nodejs.org/job/node-stress-single-test/994/ (Failures on the two win2008* jobs can be ignored, I think.) |
Trott commented Oct 12, 2016
LGTM if no CI oddities arise. |
| process.on('exit', () =>{ | ||
| assert.deepStrictEqual(events, [ 'end', 'close' ]); | ||
| }); |
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.
Would something like this work?
s.on('end',common.mustCall(()=>{s.on('close',common.mustCall(()=>{}));}));... so you can get rid of events and the exit listener.
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.
On one hand - yes, on the other - if this test will ever error, the error message will be more informative.
mcollina commented Oct 13, 2016
LGTM |
jasnell left a comment
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.
LGTM with green CI
imyller left a comment
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.
LGTM
indutny commented Oct 14, 2016
Landed in 31196ea, thank you! |
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first. PR-URL: #9066 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first. PR-URL: #9066 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
MylesBorins commented Nov 11, 2016
@indutny this lands cleanly on v4 and v6. Is this something we should consider backporting? |
indutny commented Nov 11, 2016
@thealphanerd yep |
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first. PR-URL: #9066 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first. PR-URL: #9066 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
Checklist
make -j8 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
net
Description of change
endMUST always be emitted beforeclose. However, if a handlewill invoke
uv_close_cbimmediately, or in the same JS tick -closemay be emitted first.
cc @nodejs/collaborators