Skip to content

child_process: create proper public API for channel#30165

Closed
addaleax wants to merge 1 commit into
nodejs:masterfrom
addaleax:child-process-channel-public
Closed

child_process: create proper public API for channel#30165
addaleax wants to merge 1 commit into
nodejs:masterfrom
addaleax:child-process-channel-public

Conversation

@addaleax

Copy link
Copy Markdown
Member

Instead of exposing the C++ bindings object as subprocess.channel
or process.channel, provide the “control” object that was
previously used internally as the public-facing variant of it.

This should be better than returning the raw pipe object, and
matches the original intention (when the channel property was
first added) of providing a proper way to .ref() or .unref()
the channel.

Refs: #9322
Refs: #9313

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

@addaleax addaleax added child_process Issues and PRs related to the child_process subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. labels Oct 29, 2019
@nodejs-github-bot nodejs-github-bot added the process Issues and PRs related to the process subsystem. label Oct 29, 2019
@addaleax addaleax added the review wanted PRs that need reviews. label Nov 1, 2019
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@addaleax

addaleax commented Nov 1, 2019

Copy link
Copy Markdown
Member Author

CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2081/

@nodejs/child_process

Comment thread doc/api/child_process.md Outdated
Comment thread doc/api/child_process.md Outdated
@addaleax

addaleax commented Nov 2, 2019

Copy link
Copy Markdown
Member Author

@vsemozhetbyt If it makes things easier for you, you can feel free to push to my branches directly – your suggestions are always helpful and I trust you to know how the docs should ideally look like :)

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

@addaleax Thank you) Personally, I am not so sure about my nitpicking myself, and recently I usually review in occasions not so convenient for git operations. But I am grateful for your lingering encouragement)

Comment thread lib/internal/child_process.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is refExplicitlySet necessary? Are these *Counted methods? It's the user's responsibility to pair ref and unref calls, balancing internal ref/unref calls is our responsibility. I'm not sure I see why they're needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@bnoordhuis Yeah, I’m not a fan of this either, but without this tests are failing and I wouldn’t know a better solution … the issue isn’t so much that the calls might end up unbalanced, it’s that currently, a process.channel.unref() call for example from userland is expected to unref the channel even if there are event listeners that would otherwise keep it ref()’ed.

@bnoordhuis

Copy link
Copy Markdown
Member

Oh, and for a bit of meta discussion: I added the control object as a fix for a bug, I didn't otherwise put a lot of thought into it.

Since you're thinking of promoting it to public API: do you think it's the best possible interface?

@addaleax

addaleax commented Nov 5, 2019

Copy link
Copy Markdown
Member Author

Oh, and for a bit of meta discussion: I added the control object as a fix for a bug, I didn't otherwise put a lot of thought into it.

Since you're thinking of promoting it to public API: do you think it's the best possible interface?

I think it’s fine … or, rather, I think having an API of the shape { ref(), unref(), get fd() } seems okay to me for now, and if we ever need something else I don’t think there’s anything in the way of adding that? I just don’t want to have the raw Pipe object exposed here…

@addaleax addaleax force-pushed the child-process-channel-public branch from a1a949b to 8e5f915 Compare November 5, 2019 22:15
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@bnoordhuis

bnoordhuis commented Nov 6, 2019

Copy link
Copy Markdown
Member

parallel/test-child-process-pipe-dataflow failure on Windows looks related.

edit: although it could also be #25988.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread doc/api/child_process.md Outdated
Comment thread doc/api/process.md Outdated
Comment thread lib/internal/process/stdio.js Outdated
@addaleax addaleax force-pushed the child-process-channel-public branch from f3b2b3b to b47e13e Compare November 30, 2019 17:13
@addaleax

Copy link
Copy Markdown
Member Author

@lundibundi Addressed your comments and rebased, PTAL

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread lib/internal/child_process.js Outdated
@BridgeAR

Copy link
Copy Markdown
Member

This needs a rebase.

@BridgeAR

BridgeAR commented Jan 2, 2020

Copy link
Copy Markdown
Member

Ping @addaleax

Instead of exposing the C++ bindings object as `subprocess.channel`
or `process.channel`, provide the “control” object that was
previously used internally as the public-facing variant of it.

This should be better than returning the raw pipe object, and
matches the original intention (when the `channel` property was
first added) of providing a proper way to `.ref()` or `.unref()`
the channel.

Refs: nodejs#9322
Refs: nodejs#9313
@addaleax addaleax force-pushed the child-process-channel-public branch from b47e13e to ef418e1 Compare January 3, 2020 00:53
@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed review wanted PRs that need reviews. labels Jan 3, 2020
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

nodejs-github-bot commented Jan 3, 2020

Copy link
Copy Markdown
Collaborator

BridgeAR pushed a commit that referenced this pull request Jan 3, 2020
Instead of exposing the C++ bindings object as `subprocess.channel`
or `process.channel`, provide the “control” object that was
previously used internally as the public-facing variant of it.

This should be better than returning the raw pipe object, and
matches the original intention (when the `channel` property was
first added) of providing a proper way to `.ref()` or `.unref()`
the channel.

PR-URL: #30165
Refs: #9322
Refs: #9313
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@BridgeAR

BridgeAR commented Jan 3, 2020

Copy link
Copy Markdown
Member

Landed in e65bed1 🎉

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. process Issues and PRs related to the process subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants