You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
child_process: add public API to unref ipc channel #9313
It would be nice to have a public API to unref() a child process's ipc channel. My use case for this is that I spawn a child process, send some messages back and forth via ipc, then at some point I want to detach the child process. child.unref() is not enough because that only unrefs the C++ ProcessWrap handle. Currently I have to resort to also doing child._channel.unref(). I am not sure if this should be done automatically inside child.unref() or if there should be a separate function or similar.
I've unrefed _channel, too, for similar reasons, and other reasons.
I'm not sure ._channel should be quietly unrefed when you unref the ChildProcess. It seems inconsistent to me, because child#unref() doesn't unref the other pipes, like stdout, stderr, or even pipes on descriptors higher than 2.
I'd prefer for .channel to just be documented as a property that comes into existence when 'ipc' is in the stdio: options, as .stdout and the others are. This would mean changing the name of _channel, aliasing its name so both names exist, or just documenting _channel. I'd prefer aliasing in v7, deprecating in v8, and removing in v9.
Activity
sam-github commentedon Oct 27, 2016
I've unrefed _channel, too, for similar reasons, and other reasons.
I'm not sure
._channelshould be quietly unrefed when you unref the ChildProcess. It seems inconsistent to me, becausechild#unref()doesn't unref the other pipes, like stdout, stderr, or even pipes on descriptors higher than2.I'd prefer for
.channelto just be documented as a property that comes into existence when 'ipc' is in thestdio:options, as.stdoutand the others are. This would mean changing the name of_channel, aliasing its name so both names exist, or just documenting_channel. I'd prefer aliasing in v7, deprecating in v8, and removing in v9.cjihrig commentedon Oct 27, 2016
I like that idea. I've opened #9322 as a potential starting point.
child_process: add public API for IPC channel
child_process: add public API for IPC channel
child_process: create proper public API for `channel`
child_process: create proper public API for `channel`
child_process: create proper public API for `channel`