-
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
net: handle.onread called again after UV_EOF #32487
Comments
Yeah, this is … surprising and deserving of a comment in the source code, but it seems reasonable to me. It seems like a libuv bug to me, though. Without trying it myself, which arguments does .onread() receive after the UV_EOF call? |
Unfortunately, I seem to be unable to connect to the VM so I can't try it anymore. |
{ nread: -4077, arrayBuffer: undefined } |
That |
@bnoordhuis Would you consider that an libuv bug? Again, it only happens on win10. Should I raise an issue over there? |
Only if it happens after |
Then this is a bit out of my depth. It seems to happen after |
There's an API contract that works like this:
If Node doesn't close the handle however, libuv tries to keep reading and that often results in The smart money is on Node failing to uphold its end of the contract, not libuv. |
Just so I understand, if libuv reports EOF on the readable side, then no further writes are allowed? i.e. the handle can't be half open (writable but not readable)? |
Libuv doesn't mandate what you can or cannot do but EOF usually means the other end has closed the connection (both ways.) |
node seems to assume that EOF without closing is a valid option, https://nodejs.org/api/net.html#net_new_net_socket_options, see |
Actually, that doesn't make sense. Node does call destroy always on |
This might be fixed now? |
A continuation of https://github.com/nodejs/node/pull/31806/files#r382938926.
On the following platforms the
handle.onread
is invoked again afterUV_EOF
unless the handle ishandle.close()
:ed in the same tick asUV_EOF
occurs.https://github.com/nodejs/node/blob/master/lib/internal/stream_base_commons.js#L163
https://github.com/nodejs/node/blob/master/lib/net.js#L242
The workaround in #31806 is to call
handle.readStop()
afterUV_EOF
which seems to resolve the issue.We didn't notice this previously since
handle.onread
is assigned a noop and/orhandle.close
is called, insideSocket._destroy
which in turn was invoked synchronously with'end'
.I have a VM where this is easily reproducible.
The text was updated successfully, but these errors were encountered: