-
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: destroy the socket on parse error #24757
Conversation
cc: @dougwilson |
Destroy the socket if the `'clientError'` event is emitted and there is no listener for it. Fixes: nodejs#24586
lib/_http_server.js
Outdated
@@ -512,7 +512,8 @@ function socketOnError(e) { | |||
|
|||
if (!this.server.emit('clientError', e, this)) { | |||
if (this.writable) { | |||
this.end(badRequestResponse); | |||
this.write(badRequestResponse); | |||
this.destroy(e); |
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 it make sense to wait for the write()
callback to be called?
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.
lib/_http_server.js
Outdated
@@ -512,7 +512,8 @@ function socketOnError(e) { | |||
|
|||
if (!this.server.emit('clientError', e, this)) { | |||
if (this.writable) { | |||
this.end(badRequestResponse); | |||
this.write(badRequestResponse); | |||
this.destroy(e); |
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.
We should give a chance to the event loop to write this. How about we put it into a setImmediate?
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.
Using setImmediate()
would make things even more race-y. I think it’s either using the write callback or not delaying it at all (which is still race-y, but probably more consistent?).
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
Can you please verify that http://npm.im/on-finished tests pass with this patch? |
Will do later today. |
Btw we also need #24738 as we had a regression in v11.2.0 and there are cases where |
|
Landed in ff7d053 |
Destroy the socket if the `'clientError'` event is emitted and there is no listener for it. Fixes: nodejs#24586 PR-URL: nodejs#24757 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Ah, nice fix. |
This lands cleanly on 10.x. How time sensitive is it to get this out in LTS? |
@MylesBorins I would say as soon as possible. |
We talked about it at today's @nodejs/tsc meeting and we think this fix should be released asap. |
/cc @codebytere please pick up this commit in the 10.x release
…On Wed, Dec 5, 2018, 7:28 AM Matteo Collina ***@***.*** wrote:
We talked about it at today's @nodejs/tsc
<https://github.com/orgs/nodejs/teams/tsc> meeting and we think this fix
should be released asap.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24757 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAecV3-rtn_4KT6_G_PWC3cWXeC0ztPvks5u17vRgaJpZM4Y8LBu>
.
|
Destroy the socket if the `'clientError'` event is emitted and there is no listener for it. Fixes: nodejs#24586 PR-URL: nodejs#24757 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Destroy the socket if the
'clientError'
event is emitted and there isno listener for it.
Fixes: #24586
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes