-
Notifications
You must be signed in to change notification settings - Fork 30k
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
child_process: remove use of stream private state #29358
Conversation
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 this is correct, yes. I’ve added the dont-land
labels for v12.x and v10.x so that, just in case of unexpected breakage (and sadly, this code is rather fragile), this doesn’t introduce a regression.
lib/internal/child_process.js
Outdated
@@ -298,8 +298,7 @@ function flushStdio(subprocess) { | |||
// which data can be read from a stream, e.g. being consumed on the | |||
// native layer directly as a StreamBase. | |||
if (!stream || !stream.readable || | |||
stream._readableState.readableListening || | |||
stream[kIsUsedAsStdio]) { | |||
stream[kIsUsedAsStdio]) { |
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.
stream[kIsUsedAsStdio]) { | |
stream[kIsUsedAsStdio]) { |
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.
Alternatively, it should be able to fit on one line now:
if (!stream || !stream.readable || stream[kIsUsedAsStdio]) {
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 @mscdex for the suggestion. Updated the PR accordingly.
@addaleax I'd prefer to land this on Node 12 to catch a regression early |
PR-URL: #29358 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Landed in f9c16b8 |
PR-URL: #29358 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
In child_process.js L#301, the state
stream._readableState.readableListening
is used to determine if any paused stdio streams exist, and if so, theresume()
method is used to flush it. Checking this state seems unnecessary as theresume()
method has no effect on the streams subscribed withreadable
event. Also, all existing tests pass even after removing it.If this is correct analysis, this PR includes change as part of the issue #445, to remove direct references to internal state of the stream implementation.
cc: @addaleax @mcollina
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes