When using isolate the .fork would break because it had
no .disconnect method. This remove the exit handler there
would call .disconnect since it was not required.
It also change .disconnect to throw if the channel is closed,
this was not possible before because .disconnect would be called
twice.
target.connected = true;
target.disconnect = function() {
- if (!this.connected) return;
+ if (!this.connected) {
+ this.emit('error', new Error('IPC channel is already disconnected'));
+ }
// do not allow messages to be written
this.connected = false;
if (!options.thread) setupChannel(child, options.stdinStream);
- // Disconnect when the child process exits.
- child.once('exit', child.disconnect.bind(child));
-
return child;
};
// ready to be disconnected
if (data === 'ready') {
child.disconnect();
+ assert.throws(child.disconnect.bind(child), Error);
return;
}