Skip to content

Commit 27d0eb0

Browse files
cjihrigrvagg
authored andcommitted
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: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
1 parent 178f308 commit 27d0eb0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/internal/child_process.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,9 @@ function handleMessage(target, message, handle) {
715715
message.cmd.slice(0, INTERNAL_PREFIX.length) === INTERNAL_PREFIX) {
716716
eventName = 'internalMessage';
717717
}
718-
target.emit(eventName, message, handle);
718+
process.nextTick(() => {
719+
target.emit(eventName, message, handle);
720+
});
719721
}
720722

721723
function nop() { }

0 commit comments

Comments
 (0)