Skip to content

Commit

Permalink
lib: fix ERR_IPC_CHANNEL_CLOSED send error
Browse files Browse the repository at this point in the history
Node.js 9.x emits the 'error' event asynchronously.  That means catching
it with a try/catch statement no longer works.

Fixes: nodejs/node#16322
  • Loading branch information
bnoordhuis authored and rvagg committed Oct 30, 2017
1 parent 1ee4adb commit 101c9c8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 101c9c8

Please sign in to comment.