-
Notifications
You must be signed in to change notification settings - Fork 29.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
http: fix res emit close before user finish #20941
Conversation
Another possible solution is to use |
@ronag Thanks for the quick fix :) |
This is def urgent for a 10.2.1 - without this fix end-of-stream, pump and most userland stream stuff using those are broken when using http streams |
lib/_http_server.js
Outdated
@@ -562,7 +562,7 @@ function resOnFinish(req, res, socket, state, server) { | |||
|
|||
res.detachSocket(socket); | |||
req.emit('close'); | |||
res.emit('close'); | |||
process.nextTick(emitCloseNT.bind(res)); |
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.
You could also do process.nextTick(emitCloseNT, res)
to avoid the bind and accept res
as an arg in your emitCloseNT function
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.
this will be better.
/cc @MylesBorins |
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
+1 to fast tracking. |
res.on('finish', common.mustCall((() => { | ||
assert.strictEqual(resClosed, false); | ||
}))); | ||
res.on('close', common.mustCall((() => { |
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.
you have an unneeded paran around the arrow fn here which the linter complains about
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.
if everything else is green I'll go ahead and fix that while landing
0119e3a
to
a07ea85
Compare
Fixed comments. |
The other fix for 10.2.1 has been landed. As soon as this one lands we should be ready to go for 10.2.1 |
Kicked off another CI based on new changes |
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 but the comment should be addressed (it could also be removed while landing).
}))); | ||
res.on('close', common.mustCall(() => { | ||
resClosed = true; | ||
// assert.strictEqual(res._writableState.ended, true); |
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.
Please remove commented code.
The failures on arm will all infra related. I've fixed the linting error and removed comment when landing. landed in 8ce20af |
PR-URL: #20941 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #20941 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Thanks everyone |
Changes introduced in: nodejs/node#20941 nodejs/node#20611
Fixes a regression caused by #20611 which breaks
eos
,pump
andpumpify
.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes