Skip to content

Commit

Permalink
lib: fix worker threads can't read stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
leeight committed Nov 26, 2018
1 parent e958ee7 commit d2beb1c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,22 @@ class Worker extends EventEmitter {
case messageTypes.STDIO_PAYLOAD:
{
const { stream, chunk, encoding } = message;
return this[kParentSideStdio][stream].push(chunk, encoding);
if (this[kParentSideStdio]) {
this[kParentSideStdio][stream].push(chunk, encoding);
} else {
debug(`[${threadId}] explicitly closes stdout for ${this.threadId}`);
}
return;
}
case messageTypes.STDIO_WANTS_MORE_DATA:
{
const { stream } = message;
return this[kParentSideStdio][stream][kStdioWantsMoreDataCallback]();
if (this[kParentSideStdio]) {
this[kParentSideStdio][stream][kStdioWantsMoreDataCallback]();
} else {
debug(`[${threadId}] explicitly closes stdout for ${this.threadId}`);
}
return;
}
}

Expand Down

0 comments on commit d2beb1c

Please sign in to comment.