-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
tty: implement ReadStream._final to avoid ENOTCONN on .end() #22900
Conversation
Is this also a change that came with the libuv TTY changes? My gut feeling would be that ignoring |
Yes.
I think it's still valid for |
I know why it’s being emitted… I guess my main issue with this approach is that it adds more special handling for different types of streams, when we’ve been putting some effort into reducing exactly that. Conceptually, the Alternatively, would it make sense to skip the |
I'll do that instead. It's more consistent. |
I'm not super confident about this change. Specifically because |
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.
Thanks!
Specifically because
process.stdin.write()
would likely emit anENOTCONN
as well. I think we should error in that case.
I agree, silently swallowing input data is a different thing.
I'll see what |
CI seems to fail? I'm not sure about the exact specifics but it sounds reasonable. |
Let's try CI: https://ci.nodejs.org/job/node-test-pull-request/17251/ |
@addaleax handling it within |
@@ -359,7 +364,7 @@ Socket.prototype._final = function(cb) { | |||
debug('_final: not ended, call shutdown()'); | |||
|
|||
// otherwise, just shutdown, or destroy() if not possible | |||
if (!this._handle || !this._handle.shutdown) { | |||
if (!this[kShouldShutdown] || !this._handle || !this._handle.shutdown) { |
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.
I think the issue might be that this runs destroy()
when it previously didn’t.
I can try it too (later), but maybe undoing this line change and adding if (!this[kShouldShutdown]) return cb();
below works?
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.
It doesn't because the writable: false
parameter that is passed in to the net.Socket
constructor does control other behaviors internally, and it does not mean "this is half-open".
If you want to give it a shot, feel free to push here. Otherwise we revert to the _final
solution.
@@ -66,6 +66,7 @@ function ReadStream(fd, options) { | |||
} | |||
inherits(ReadStream, net.Socket); | |||
|
|||
|
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.
Unrelated change?
@@ -245,6 +246,10 @@ function Socket(options) { | |||
options.writable = options.writable || false; | |||
const { allowHalfOpen } = options; | |||
|
|||
// Needed to avoid to call uv_shutdown during _final |
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.
"to call" -> "calling"
I think libuv/libuv@4049879 may have fixed this as well, by making things work again on the libuv side? |
I think so. Have you tested it? |
@mcollina Just checked, and yes, it does fix |
Would prefer to wait for libuv patch (should be soon enough?)
Let's wait for that. |
I’ve opened a PR with only the test changes here (and attribution to you), so I hope it’s okay to close this. You know what to do if I’m mistaken :) |
Fixes: #22814.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes