diff --git a/lib/child_process.js b/lib/child_process.js index 0a0ae920528..d46caae4b6a 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -102,7 +102,10 @@ function setupChannel(target, channel) { throw new TypeError('message cannot be undefined'); } - if (!this.connected) throw new Error('channel closed'); + if (!this.connected) { + this.emit('error', new Error('channel closed')); + return; + } // For overflow protection don't write if channel queue is too deep. if (channel.writeQueueSize > 1024 * 1024) {