-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: add public API for IPC channel #9322
Conversation
|
||
Object.defineProperty(target, '_channel', { | ||
get() { return target.channel; }, | ||
set(val) { target.channel = val; }, |
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.
Setting it is DEEP into undefined behaviour, I guess its backwards compatible... but I can't think of a reason to take a shot-gun to the ChildProcess internals.
target._channel = channel; | ||
target.channel = channel; | ||
|
||
Object.defineProperty(target, '_channel', { |
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.
maybe a note that this can be deprecated in node 8.x?
Looks like a good direction to me. |
Seems worthwhile. |
OK, added docs and a code comment allowing deprecation in version 8. |
@ChALkeR ... can you do a search for uses of |
I just looked for my own uses, and I believe this change also applies/creates I'd love to know how @ChALkeR does his magic,btw, but looking at my code, I think a number of my uses are in test code, which might not show up on npmjs.org. |
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.
LGTM with the additional doc that @sam-github suggests.
I'm not sure of the best way to add documentation for those other things. The |
@cjihrig are you sure that there is no That setup target function that you modified is, IIRC (but its been a year), also called with There might be a And if there isn't the two APIs above... maybe there should be? |
Ah, yea In |
OK, added documentation for |
* {Object} A pipe representing the IPC channel to the child process. | ||
|
||
The `child.channel` property is a reference to the child's IPC channel. If no | ||
IPC channel currently exists, this value is `undefined`. |
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.
the property is
undefined
maybe? It seems odd to me to say "The X property is blah, this value is undefined", why speak of a property in the first sentence, and a value in the second?
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.
Updated to use property consistently.
<!-- YAML | ||
added: REPLACEME | ||
--> | ||
|
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.
- {Object} A pipe representing the IPC channel to the child process.
Not needed here, the style of docs is different in child_process and process?
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.
Yes, I noticed that the style of the docs in this file are slightly different. I think a good first contribution would be to bring additional consistency to this file. For example, see https://nodejs.org/api/process.html#process_process_connected vs. https://nodejs.org/api/child_process.html#child_process_child_connected.
LGTM Some minor comments on the doc wording, feel free to address if you agree, or leave as-is if you don't. |
CI failures all looked infrastructure related, but going to try to get a better run: https://ci.nodejs.org/job/node-test-pull-request/4758/ |
This commit adds a public channel property to ChildProcess. The existing _channel property is aliased to the new property, with the intention of deprecating and removing it in the future. Fixes: nodejs#9313 PR-URL: nodejs#9322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
This commit adds a public channel property to ChildProcess. The existing _channel property is aliased to the new property, with the intention of deprecating and removing it in the future. Fixes: #9313 PR-URL: #9322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
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
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
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>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
child_process
Description of change
This commit adds a public
channel
property toChildProcess
. The existing_channel
property is aliased to the new property, with the intention of deprecating and removing it in the future.I will add the documentation if we decide to move forward with this.Fixes: #9313