Skip to content

Commit d59917b

Browse files
committed
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 <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
1 parent dab0987 commit d59917b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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)