GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tty: implement ReadStream._final to avoid ENOTCONN on .end() by mcollina · Pull Request #22900 · nodejs/node

Conversation

@mcollina

@mcollina mcollina commented Sep 17, 2018

Copy link
Copy Markdown
Member

Fixes: #22814.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot

nodejs-github-bot commented Sep 17, 2018

Copy link
Copy Markdown
Collaborator

@mcollina build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/906/pipeline

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added the tty Issues and PRs related to the tty subsystem. label Sep 17, 2018
@addaleax

addaleax commented Sep 17, 2018

Copy link
Copy Markdown
Member

Is this also a change that came with the libuv TTY changes?

My gut feeling would be that ignoring ENOTCONN during shutdown of any socket would also be a valid fix? Is there ever any benefit from reporting that error back to the user, if it happens while shutting down?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Sep 17, 2018

Copy link
Copy Markdown
Member Author

Is this also a change that came with the libuv TTY changes?

Yes.

My gut feeling would be that ignoring ENOTCONN during shutdown of any socket would also be a valid fix? Is there ever any benefit from reporting that error back to the user, if it happens while shutting down?

I think it's still valid for net.Socket. In this case it is happening because the writable side has never been opened, so it cannot really be shutdown (shutdown only works on writables).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Sep 17, 2018

Copy link
Copy Markdown
Member

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 TTY code should not contain any stream specifics, imo…

Alternatively, would it make sense to skip the shutdownSocket call in net.js if stream.writable was false when the stream was created?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Sep 17, 2018

Copy link
Copy Markdown
Member Author

Alternatively, would it make sense to skip the shutdownSocket call in net.js if stream.writable was false when the stream was created?

I'll do that instead. It's more consistent.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
net: do not call uv_shutdown if it did not start as writable
b30b568
Fixes: nodejs#22814.
@mcollina
mcollina force-pushed the fix-22814 branch from cfbf4c0 to b30b568 Compare September 17, 2018 14:24
@mcollina

mcollina commented Sep 17, 2018

Copy link
Copy Markdown
Member Author

I'm not super confident about this change. Specifically because process.stdin.write() would likely emit an ENOTCONN as well. I think we should error in that case. I'm not sure if we should skip it in this one as well because it is totally harmless. However, calling .end() on what is essentially a readable should not be ok according to the new libuv logic.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax previously approved these changes Sep 17, 2018
View reviewed changes

@addaleax addaleax left a comment

Copy link
Copy Markdown
Member

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 an ENOTCONN as well. I think we should error in that case.

I agree, silently swallowing input data is a different thing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mcollina

mcollina commented Sep 17, 2018

Copy link
Copy Markdown
Member Author

I'll see what process.stdin.write() does and open a PR in case.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Sep 17, 2018

Copy link
Copy Markdown
Contributor

CI seems to fail? I'm not sure about the exact specifics but it sounds reasonable.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Sep 17, 2018

Copy link
Copy Markdown
Member Author

Let's try CI: https://ci.nodejs.org/job/node-test-pull-request/17251/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Sep 17, 2018

Copy link
Copy Markdown
Member Author

@addaleax handling it within net is not working. I think we should go back to the _final override.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax reviewed Sep 17, 2018
View reviewed changes
Comment thread lib/net.js

// otherwise, just shutdown, or destroy() if not possible
if (!this._handle || !this._handle.shutdown) {
if (!this[kShouldShutdown] || !this._handle || !this._handle.shutdown) {

@addaleax addaleax Sep 17, 2018

Copy link
Copy Markdown
Member

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina Sep 18, 2018

Copy link
Copy Markdown
Member Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig approved these changes Sep 18, 2018
View reviewed changes
Comment thread lib/tty.js
}
inherits(ReadStream, net.Socket);


@cjihrig cjihrig Sep 18, 2018

Copy link
Copy Markdown
Contributor

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/net.js
options.writable = options.writable || false;
const { allowHalfOpen } = options;

// Needed to avoid to call uv_shutdown during _final

@cjihrig cjihrig Sep 18, 2018

Copy link
Copy Markdown
Contributor

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"

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@joyeecheung joyeecheung mentioned this pull request Sep 18, 2018
CI failures: 20180918 nodejs/reliability#16
Closed
@addaleax

addaleax commented Sep 19, 2018

Copy link
Copy Markdown
Member

I think libuv/libuv@4049879 may have fixed this as well, by making things work again on the libuv side?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Sep 19, 2018

Copy link
Copy Markdown
Member Author

I think so. Have you tested it?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Sep 19, 2018

Copy link
Copy Markdown
Member

@mcollina Just checked, and yes, it does fix ./node -e 'process.stdin.end();' when run on a TTY. 🎉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Sep 19, 2018
View reviewed changes
@addaleax
addaleax dismissed their stale review September 19, 2018 16:36

Would prefer to wait for libuv patch (should be soon enough?)

@mcollina

mcollina commented Sep 19, 2018

Copy link
Copy Markdown
Member Author

Let's wait for that.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax pushed a commit to addaleax/node that referenced this pull request Sep 24, 2018
@mcollina @addaleax
test: add process.stdin.end() TTY regression test
c488603
Fixes: nodejs#22814
Refs: nodejs#22900
@addaleax addaleax mentioned this pull request Sep 24, 2018
test: add process.stdin.end() TTY regression test #23051
Closed
3 tasks done
@addaleax

addaleax commented Sep 24, 2018

Copy link
Copy Markdown
Member

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 :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax closed this Sep 24, 2018
@cristianberroeta cristianberroeta mentioned this pull request Oct 7, 2018
fix ENOTCONN error in Node v10.1.0 workshopper/adventure#15
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax addaleax left review comments
@jasnell jasnell jasnell approved these changes
@cjihrig cjihrig cjihrig approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

tty Issues and PRs related to the tty subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@mcollina @nodejs-github-bot @addaleax @Fishrock123 @jasnell @cjihrig
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.