From ab32e9e04346fe627e01b3b9a852f6c4663681f2 Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Tue, 31 Jan 2012 19:51:01 +0100 Subject: [PATCH] child_process: emit 'channel closed' error instead of throwing --- lib/child_process.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) {