Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Error: IPC channel is already disconnected

Error: IPC channel is already disconnected


Where/when should I catch this error?

Error: IPC channel is already disconnected

This is called from child_process (using cluster) module when I call .disconect() 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)
Problem courtesy of: codename-


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.

Solution courtesy of: codename-


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Error: IPC channel is already disconnected


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription