-
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: detach socket from IncomingMessage on keep-alive #32153
Conversation
@szmarczak I think this is the fix you were looking for. |
I'm not sure whether setting
|
7304bc7
to
4ed671f
Compare
Looks amazing, you're a lifesaver! |
If the socket is not detached then a future call to res.destroy (through e.g. pipeline) would unecessarily kill the socket while its in the agent free list.
4ed671f
to
30601b5
Compare
CITGM looks good |
If the socket is not detached then a future call to res.destroy (through e.g. pipeline) would unecessarily kill the socket while its in the agent free list. PR-URL: #32153 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in c1b2f6a |
Since this isn't a breaking change, will this be backported? |
@szmarczak it's labeled as semver-major, sorry :( |
res.socket has been detached from IncomingMessage in node-v14.x Reference: nodejs/node#32153
res.socket has been detached from IncomingMessage in node-v14.x Reference: nodejs/node#32153
res.socket has been detached from IncomingMessage in node-v14.x Reference: nodejs/node#32153
@@ -48,7 +48,7 @@ const server = http.createServer(common.mustCall((req, res) => { | |||
response.on('end', common.mustCall(() => { | |||
request1.socket.destroy(); | |||
|
|||
response.socket.once('close', common.mustCall(() => { | |||
request1.socket.once('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.
This looks like it's no longer testing what it used to be testing (just working around the fact that response.socket
is cleared now by attaching the event to an unrelated socket?). Proper fix would be to leave the event on response.socket
and just attach it before the socket is cleared (up 3 lines, right after response.pipe
)?
I'm not actually familiar with this code, just in here since this test started breaking on Node v14 over in http-parser-js, which has a fork of some of these tests, but I noticed the old code also had a big comment about how important the timing/ordering of attaching that event listener was.
If the socket is not detached then a future call to res.destroy
(through e.g. pipeline) would unecessarily kill the socket while
its in the agent free list.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes