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 committed May 24, 2016
1 parent dab0987 commit d59917b
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 d59917b

Please sign in to comment.