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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
  • Loading branch information
cjihrig authored and Myles Borins committed Jul 1, 2016
1 parent e319d76 commit 9ac3971
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 @@ -692,7 +692,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 9ac3971

Please sign in to comment.