child_process: emit 'channel closed' error instead of throwing

pull/24503/head
Andreas Madsen 2012-01-31 19:51:01 +01:00 committed by isaacs
parent 89653cb32f
commit ab32e9e043
1 changed files with 4 additions and 1 deletions

View File

@ -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) {