codename- codename- - 1 year ago 197
Node.js Question

Error: IPC channel is already disconnected

Where/when should I catch this error?

Error: IPC channel is already disconnected

This is called from
) module when I call
multiple times. I know that I shouldn't call this twice (or more), but sometimes I don't have control over this. Eventually how to prevent calling this multiple times? This code doesn't works:

try {
if (worker.state !== "disconnected" && worker.state !== "dead") {
} catch (error) {}


This is stack trace of this error:

throw arguments[1]; // Unhandled 'error' event
Error: IPC channel is already disconnected
at (child_process.js:392:26)
at ProgressTracker.callback (cluster.js:437:20)
at ProgressTracker.check (cluster.js:94:32)
at Object.Worker.disconnect [as 44:2] (cluster.js:445:16)
at handleResponse (cluster.js:149:41)
at respond (cluster.js:170:5)
at handleMessage (cluster.js:180:5)
at process.EventEmitter.emit (events.js:126:20)
at handleMessage (child_process.js:269:12)
at (child_process.js:293:9)

Answer Source

This error should be handled in worker file. For example using this code:

process.on("uncaughtException", function (error) {
  if (error.toString() !== 'Error: IPC channel is already disconnected') {

All tries for catching it from parent script was unsuccessful.
I have hope that this help someone deal with this problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download