-
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
net: aborted socket incorrectly ends gracefully #31916
Comments
@addaleax Maybe has an idea? I notice there is no nodejs/net team. Who more is usually a good ping on |
@ronag sorry, I'm not understanding why this is an issue. IIUIC, if you're not writing any data while the socket is closing with |
I am not very knowledgeable on TCP, but I guess in the case of I'm not sure if there is such a thing as graceful and non graceful disconnect in tcp and how and whether that applies to node sockets, so please take this issue with a grain of salt. |
@ronag Destroy is entirely a node thing, it means "stop reading, stop writing, close socket". .end() means "write all queued data, write FIN, then close socket" (unless half open is allowed, then it means "write all queued data, write FIN (using SHUTDOWN), then read data until FIN or error, then close"). destroy doesn't mean "send a TCP error indication to the peer". |
afaik, |
I was under the impression that |
To send the |
.destroy() just closes while the node.js streams are not done, it doesn't specifically send a RST. It should be understood as "discard data queued in the stream; .end()". destroy might appear to send RST occaisonally, because TCP close() can cause a RST in some very specific circumstances, such as more data is received from the other side after the socket was closed, or there is data received in this host's TCP buffers and not yet read by uv, but some of those situations could occur with |
Just to clarify. Are we happy with the current behavior and what is the preferred behavior in a perfect world? For me |
Yes, we are OK with current situation, though not with the docs! Your expectations are based on assumptions about how TCP works (or desires for how it could work?) that don't reflect how it actually works, sorry! Protocols on top of TCP are responsible for determining whether data was completely exchanged. HTTP does this, TLS does this, etc. |
I'm good with this. Thanks for clarifying! |
@sam-github: How would you like to improve the docs? |
Refer back to streams docs for further and more accurate description of behavior details. Refs: nodejs#31916
The docs have to make clear that destroy() rips node.js streams apart, but that they do not explicitly cause TCP stream reset ( It should clarify what the defined behaviour is aftwards wrt. to read/write (and their callbacks), error events, and also enumerate the undefined behaviour. @ronag you likely have the best sense of that, as you seem to be going through and finding all the inconsistencies. That would be enough to be clear for people familiar with TCP networking, but for many Node.js users, they are not clear on the bi-directional nature of TCP streams, and what they can expect of |
@sam-github Thanks. I'll try to draft something based on that.
Will add something along these lines.
This should be part of the streams docs. Work in progress. |
Refer back to streams docs for further and more accurate description of behavior details. Refs: #31916 PR-URL: #32811 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Refer back to streams docs for further and more accurate description of behavior details. Refs: #31916 PR-URL: #32811 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Refer back to streams docs for further and more accurate description of behavior details. Refs: nodejs#31916 PR-URL: nodejs#32811 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Refer back to streams docs for further and more accurate description of behavior details. Refs: #31916 PR-URL: #32811 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Refer back to streams docs for further and more accurate description of behavior details. Refs: #31916 PR-URL: #32811 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
The following test will fail since the client socket will emit
'end'
and noECONNRESET
, even though the server calleddestroy()
instead ofend()
.Platform: MacOS
The text was updated successfully, but these errors were encountered: