Uh oh!
There was an error while loading. Please reload this page.
tty: set the handle to blocking mode - #6816
Conversation
indutny
commented
May 17, 2016
I have a deja vu here... Is it like 3rd time we re-enable it? |
indutny
commented
May 17, 2016
Am I right that running |
addaleax
commented
May 17, 2016
@indutny This should only affect |
indutny
commented
May 17, 2016
@addaleax oh, right! Thank you. LGTM then, I have no issues with this. |
mscdex
commented
May 17, 2016
Shouldn't there at least be an official way to change the behavior (in case someone needs/wants async)? |
Fishrock123
commented
May 17, 2016
Haha, not quite. ;) @mscdex Official? Idk. But you can still do That being said, I can't think of a reason you'd need async in a TTY? Maybe if only one stream is to a TTY? |
mscdex
commented
May 17, 2016
@Fishrock123 I meant a way without accessing an underscored property. |
saghul
commented
May 17, 2016
LGTM. (fingers crossed so we don't open a can of worms). /cc @bnoordhuis I believe this whole thing make some sense in your brain, I'd love to see your yay or nay here. |
Builds on nodejs#6816, adds API for explicitly setting non-blocking mode without relying on `_`-prefixed internal property. Adds documentation.
jasnell
commented
May 17, 2016
@mscdex ... like this? jasnell@4982550 |
jasnell
commented
May 17, 2016
This PR should include a documentation update that (a) describes the default behavior of |
@jasnell So, there are a couple issues with your API proposal. The biggest is that actually creating TTY streams isn't particularly supported:
In fact, I've tried to make tty streams before and found it's virtually impossible. You can only make one if the However, exposing a
I doubt that is useful due to the above, or the correct place to put it, since no-one will go looking for the TTY module from I will add a note to where the existing note is for file piping though: https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_process_stderr |
c3bfcb0 to
5645984CompareFishrock123
commented
May 17, 2016
Updated with docs note. |
There was a problem hiding this comment.
nit: It’s usually stylized as Windows in the docs.
5645984 to
8a33b16Compareaddaleax
commented
May 17, 2016
LGTM |
8a33b16 to
2504cf5Comparemscdex
commented
May 17, 2016
@jasnell Something like that would be ideal of course, but even if there was a way to simply change the behavior once on startup. I'm not sure what that would look like or if enough people would be interested in supporting something like that though ... |
jasnell
commented
May 17, 2016
@mscdex ... I'm definitely for it (either API or command line switch) but given the discussion I doubt we'd get consensus to add it so I'm going to just drop it. |
jasnell
commented
May 17, 2016
I would say that this looks like a semver-major change but I know there will be disagreement with that. |
@jasnell Could you give an example of what you imagine might break because of this change? |
Fishrock123
commented
May 17, 2016
I can imagine a lot of things that are already breaking without this change. ;) |
Fishrock123
commented
May 17, 2016
jasnell
commented
May 17, 2016
@addaleax ... not off hand but it is a change in the established default behavior, which would technically qualify it as a semver-major. Note that I didn't add the label ;-) ... I'm quite certain that I'm in the minority. |
Fishrock123
commented
May 17, 2016
Sorta. It gets tricky here because on OS X it appears to have previously actually blocked when it wasn't supposed to so the majority of the CLI users never noticed this because it never changed on their platform sooner. So... the previous behavior is actually more established there, and due to previous versions of node.js, also across the board I think. Additionally, I'm unsure if |
I'm more inclined to say |
addaleax
commented
May 17, 2016
As far as I can tell, the only visible difference would be in timing, no? And unlike with pipes, for |
There was a problem hiding this comment.
Nit: comma after 1
Nit: backticks around stdout and stderr
Nit: async->asynchronous
Trott
commented
Jul 15, 2016
Left some nits on the documentation prose, but nothing that I think must happen before landing. (In other words: Don't interpret my nits as me objecting to this landing.) |
MylesBorins
commented
Jul 15, 2016
@Fishrock123 is this something that should be included in v4.5.0? |
saghul
commented
Jul 16, 2016
@kzc A note to remember: when stdio was made blocking on macOS that was meant to restore the behavior aas in v4.x On other Unix systems it never blocked. We are changing that now. Is it a good or a bad thing? I no longer know. |
@saghul I know the history well. The blocking on Mac was initially inadvertently introduced as result of a bug pre-node 4.x when trying to re-open the tty - ironically to not block stdio - and somehow this blocking stdio behavior on Mac became grandfathered as the status quo. Whether this PR is good or bad, it just addresses that inconsistency on UNIX platforms. #6816 (comment) sums up my view. Blocking stdio tty alone is not enough to fix the many long standing problems with node stdio. Something like #6773 is still needed to resolve truncated piped stdout/stderr and some similar fix is still required to flush piped stdio in the event of an uncaught exception. Once node is in the process of an abrupt exit and the event loop is no longer running (although not destroyed) there's zero downside to flushing stdout and stderr as users would reasonably expect. As I don't watch these node issue/PR threads any longer please use my @ handle if you want to get any other feedback. |
saghul
commented
Jul 17, 2016
@kzc Sure, I know we are currently not in a very good place. Thanks for your efforts so far. |
Fishrock123
commented
Jul 18, 2016
@thealphanerd Give it's potentially debatable if this is a major, I'm going to say no. |
Fishrock123
commented
Jul 18, 2016
I consider it a non-breaking bugfix given that:
|
Refs: nodejs#1771 Refs: nodejs#6456 Refs: nodejs#6773 Refs: nodejs#7743 PR-URL: nodejs#6816
Fishrock123
commented
Jul 18, 2016
New CI: https://ci.nodejs.org/job/node-test-pull-request/3324/ @jasnell Could you take a look at this again and let us know if you are comfortable with it? |
| Note: `process.stderr` and `process.stdout` differ from other Node.js streams | ||
| in several ways: | ||
| 1. They cannot be closed ([`end()`][] will throw). | ||
| 2. They never emit the [`'finish'`][] event. |
There was a problem hiding this comment.
We don't need the additional square brackets for links I guess.
There was a problem hiding this comment.
Huh? These should use links defined at the bottom of the file...?
There was a problem hiding this comment.
If we have defined them at the bottom the empty square brackets are not necessary I think
jasnell
commented
Jul 20, 2016
LGTM but we'll need to message this properly. While I believe there is consensus around landing this as a bug fix, it is technically a fairly significant change in behavior that should technically be tagged as a semver-major. There should be a release candidate cycle for any release that this goes out in just to be on the safe side. |
If it must land in a semver-major, it could. I do not think it is reasonable to see this as an API change however, so I think it may be worth our while to get this in before v6 goes LTS. |
addaleax
commented
Aug 8, 2016
This still LGTM, and I’m still +1 on not seeing this as a semver-major because afaict, this doesn’t necessarily represent a visible behavioural change. |
Fishrock123
commented
Aug 8, 2016
Guess we're clear to land... or as clear as it will get. @jasnell how do you propose we message it? |
jasnell
commented
Aug 8, 2016
Twitter PSA at the very least (I can do that in just a minute). Even tho this will land as a patch, we need to make sure it's called out explicitly in the release notes. Beyond that, I'm not sure what else. |
jasnell
commented
Aug 8, 2016
I would definitely recommend that we do a release candidate for whatever release this lands in. |
I’ll be landing this later today if there are no objections and nobody else does before me, this has been lying around long enough. edit: One more CI: https://ci.nodejs.org/job/node-test-commit/4501/ |
addaleax
commented
Aug 10, 2016
Landed in ab3306a |
Checklist
Affected core subsystem(s)
tty, process
Description of change
See discussion at:
process.exit()#6773cc @nodejs/ctc @isaacs@ksc@saghul etc
Note: we still have more investigation to do but this is looking like it is probably the correct thing to do.