Skip to content

Commit

Permalink
child_process: emit IPC messages on next tick
Browse files Browse the repository at this point in the history
Currently, if an IPC event handler throws an error, it can
cause the message to not be consumed, leading to messages piling
up. This commit causes IPC events to be emitted on the next tick,
allowing the channel's processing logic to move forward as
normal.

Fixes: #6561
PR-URL: #6909
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
  • Loading branch information
cjihrig authored and rvagg committed Jun 2, 2016
1 parent 178f308 commit 27d0eb0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,9 @@ function handleMessage(target, message, handle) {
message.cmd.slice(0, INTERNAL_PREFIX.length) === INTERNAL_PREFIX) {
eventName = 'internalMessage';
}
target.emit(eventName, message, handle);
process.nextTick(() => {
target.emit(eventName, message, handle);
});
}

function nop() { }
Expand Down

0 comments on commit 27d0eb0

Please sign in to comment.