-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
socket.write() emits error synchronously when socket was closed by peer #24111
Comments
No, let's fix this. I fear there will be some ecosystem breakage, but I would say that's ok. |
I would strongly prefer for the fix to be that we have as little |
I think |
@sam-github I don't think so, see https://github.com/nodejs/node/blob/master/lib/net.js#L611. Can you reproduce? |
Can't repro, I'm not sure anymore what I saw when I took that note. Write sync emitting an error isn't specific to server half-close, it looks like its just generally how it works.
|
This commit makes those errors caused by calling `net.Socket.write()` after sockets ending be emitted in the next tick. PR-URL: nodejs#24457 Fixes: nodejs#24111 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Fixed in 9389b46 |
(Feel free to re-open if you think this should stay open until that change is in a release, or all relevant releases, or whatever.) |
This commit makes those errors caused by calling `net.Socket.write()` after sockets ending be emitted in the next tick. PR-URL: nodejs#24457 Fixes: nodejs#24111 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Is it just on fixed on node 12.8.0? From my side, other versions still have this problem. |
Fixed in 12.0.0 and newer. It will not be fixed in older release lines because the fix is considered a breaking change. |
EDIT: forgot output:
I would expect error to be emitted in the next tick, as it normally would for a runtime error. This matters because normally code like this would work:
but in the case of a TCP close by the peer, the error event will never be caught in the above.
I think the TODO in the source is referring to this:
node/lib/net.js
Line 409 in 5c2d555
@mcollina what do you think? Is how net sockets are working here how a write stream is expected to work?
The text was updated successfully, but these errors were encountered: