-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: emit ECONNRESET if no 'aborted' listener #28677
Conversation
8ce5c8d
to
24f4a00
Compare
Would you mind adding a unit test? |
24f4a00
to
0289de3
Compare
@mcollina @benjamingr docs and tests added |
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
0289de3
to
37554a3
Compare
@mcollina Thank you so much for the suggestion. This would make my life much easier. |
1 similar 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
Hm, I have more tests to fix... |
@mcollina May I deprecate/remove ‘aborted’ from the docs as well? Or is that a step too far? |
I would not deprecate/remove at this point. |
I think this is a pretty big breaking change as an |
@lpinca not having an aborted listener on the response is currently quite a serious bug... and something I believe unfortunately is quite common. Currently it will fail silently. From an API standpoint you should always have a error listener on the response object. But yes, this could be a sem major? |
Why? care to elaborate? |
Because you would never finish... consider the following quite common pattern: await new Promise((resolve, reject) => res
.on('error', reject)
.pipe(dst)
.on('error', reject)
.on('finish', resolve)
) If |
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.
Moving it to “change requested” as we need a new error code for this.
Hmm unconvinced, the example above is a very specific use case and I'm not very happy with enforcing either an |
37554a3
to
af06d83
Compare
Fair enough. The only other argument I can give is that it pretends to be a stream but doesn't follow the stream spec (if |
af06d83
to
147e7e2
Compare
@mcollina: Tried a different message. |
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
@lpinca what do you think? @nodejs/tsc this is likely a significant breaking change, you might want to review again. |
No strong opinion. The rationale seems sensible but I don't know if it makes sense due to the big breaking change. |
@Trott: Is anything blocking this? |
With this change, CITGM has new failures for ws: 2 failing
1) WebSocket
Connection establishing
"after each" hook:
Uncaught Error: aborted
at connResetException (internal/errors.js:566:14)
at Socket.socketCloseListener (_http_client.js:364:27)
at TCP.<anonymous> (net.js:658:12)
2) WebSocket
Connection establishing
"before each" hook for "connects when pathname is not null":
TypeError: Cannot read property 'call' of undefined
at processImmediate (internal/timers.js:439:21) koa: 3 failing
1) app.respond
when ctx.respond === false
should function (ctx):
Error: aborted
at connResetException (internal/errors.js:566:14)
at Socket.socketCloseListener (_http_client.js:364:27)
at TCP.<anonymous> (net.js:658:12)
[use `--full-trace` to display the full stack trace]
2) app.respond
when ctx.respond === false
should ignore set header after header sent:
Error: aborted
at connResetException (internal/errors.js:566:14)
at Socket.socketCloseListener (_http_client.js:364:27)
at TCP.<anonymous> (net.js:658:12)
[use `--full-trace` to display the full stack trace]
3) app.respond
when ctx.respond === false
should ignore set status after header sent:
Error: aborted
at connResetException (internal/errors.js:566:14)
at Socket.socketCloseListener (_http_client.js:364:27)
at TCP.<anonymous> (net.js:658:12)
[use `--full-trace` to display the full stack trace]
Error: mock stack null
Error: ENOENT: no such file or directory, open 'does not exist'
Error: ENOENT: no such file or directory, open 'does not exist'
Error: ENOENT: no such file or directory, open 'does not exist'
Error: ENOENT: no such file or directory, open 'does not exist'
Error: ENOENT: no such file or directory, open 'does not exist'
Error: boom! |
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.
CITGM results would seem to indicate that we have some work to do in the ecosystem before landing this. If the approvers of this PR disagree and think it can/should land at this time, feel free to clear this review.
|
Yes, I don't like it but I can live with it in ws. I'm actually more worried about similar breakage this can have on the ecosystem as per #28677 (comment). I've seen a lot of code where no |
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.
Considering the breakage in the ecosystem, I don't think we should land this.
Or it just seems to work... I think a lot of the code that don't register |
I guess adding an option/flag to enable this behavior is not an option either? I find this whole A process.'warning' if aborting and neither error nor aborted is registered? @mcollina: Is there anything more that can be done here or should we close this? |
I would close this for now, yes |
Server requests aka. IncomingMessage emits 'aborted' instead of 'error' which causes confusion when the object is used as a regular stream, i.e. if functions working on streams are passed a server request object they might not work properly unless they take this into account. Refs: nodejs/web-server-frameworks#41 PR-URL: #33172 Fixes: #28172 Refs: #28677 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Emits an ECONNRESET of response object when there is no listener for
aborted
.Refs: #28172
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes