tty: implement ReadStream._final to avoid ENOTCONN on .end()#22900
tty: implement ReadStream._final to avoid ENOTCONN on .end()#22900mcollina wants to merge 1 commit intonodejs:masterfrom
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 |
addaleax
left a comment
There was a problem hiding this comment.
Thanks!
Specifically because
process.stdin.write()would likely emit anENOTCONNas 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 |
|
|
||
| // 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.
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.
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.
| } | ||
| inherits(ReadStream, net.Socket); | ||
|
|
||
|
|
| options.writable = options.writable || false; | ||
| const { allowHalfOpen } = options; | ||
|
|
||
| // Needed to avoid to call uv_shutdown during _final |
|
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