Browse Source

child_process: emit IPC messages on next tick

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: https://github.com/nodejs/node/issues/6561
PR-URL: https://github.com/nodejs/node/pull/6909
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
v4.x
cjihrig 9 years ago
committed by Myles Borins
parent
commit
0b8124f205
  1. 4
      lib/internal/child_process.js

4
lib/internal/child_process.js

@ -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() { }

Loading…
Cancel
Save