From 101c9c88d988814b894e943e240889c584e6a110 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 19 Oct 2017 20:35:16 +0200 Subject: [PATCH] lib: fix ERR_IPC_CHANNEL_CLOSED send error Node.js 9.x emits the 'error' event asynchronously. That means catching it with a try/catch statement no longer works. Fixes: https://github.com/nodejs/node/issues/16322 --- lib/fork.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/fork.js b/lib/fork.js index cbd4011..46cf79b 100644 --- a/lib/fork.js +++ b/lib/fork.js @@ -15,17 +15,15 @@ function fork (forkModule) { , cwd: process.cwd() }) + child.on('error', function() { + // this *should* be picked up by onExit and the operation requeued + }) + child.send({ module: forkModule }) // return a send() function for this child return { - send : function (data) { - try { - child.send(data) - } catch (e) { - // this *should* be picked up by onExit and the operation requeued - } - } + send : child.send.bind(child) , child : child } }