Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

ckarande
Copy link
Contributor

In child_process.js L#301, the state stream._readableState.readableListening is used to determine if any paused stdio streams exist, and if so, the resume() method is used to flush it. Checking this state seems unnecessary as the resume() method has no effect on the streams subscribed with readable 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), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Aug 28, 2019
Copy link
Member

@addaleax addaleax left a 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.

@ckarande ckarande changed the title child_process: cleanup use of stream internal state readableListening child_process: remove use of stream private state Aug 28, 2019
@nodejs-github-bot
Copy link
Collaborator

@@ -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]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
stream[kIsUsedAsStdio]) {
stream[kIsUsedAsStdio]) {

Copy link
Contributor

@mscdex mscdex Aug 28, 2019

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]) {

Copy link
Contributor Author

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.

@mcollina
Copy link
Member

@addaleax I'd prefer to land this on Node 12 to catch a regression early

@nodejs-github-bot
Copy link
Collaborator

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 12, 2020
@nodejs-github-bot
Copy link
Collaborator

Trott pushed a commit that referenced this pull request Jan 12, 2020
PR-URL: #29358
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@Trott
Copy link
Member

Trott commented Jan 12, 2020

Landed in f9c16b8

@Trott Trott closed this Jan 12, 2020
MylesBorins pushed a commit that referenced this pull request Jan 16, 2020
PR-URL: #29358
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@codebytere codebytere mentioned this pull request Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. child_process Issues and PRs related to the child_process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants