Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit ab32e9e

Browse files
AndreasMadsenisaacs
authored andcommitted
child_process: emit 'channel closed' error instead of throwing
1 parent 89653cb commit ab32e9e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/child_process.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ function setupChannel(target, channel) {
102102
throw new TypeError('message cannot be undefined');
103103
}
104104

105-
if (!this.connected) throw new Error('channel closed');
105+
if (!this.connected) {
106+
this.emit('error', new Error('channel closed'));
107+
return;
108+
}
106109

107110
// For overflow protection don't write if channel queue is too deep.
108111
if (channel.writeQueueSize > 1024 * 1024) {

0 commit comments

Comments
 (0)