node.js - Error: IPC channel is already disconnected -
where/when should catch error?
error: ipc channel disconnected this called child_process (using cluster) module when call .disconect() multiple times. know shouldn't call twice (or more), don't have control on this. how prevent calling multiple times? code doesn't works:
try { if (worker.state !== "disconnected" && worker.state !== "dead") { worker.disconnect(); } } catch (error) {} edit:
this stack trace of error:
events.js:71 throw arguments[1]; // unhandled 'error' event ^ error: ipc channel disconnected @ process.target.disconnect (child_process.js:392:26) @ progresstracker.callback (cluster.js:437:20) @ progresstracker.check (cluster.js:94:32) @ object.worker.disconnect [as 44:2] (cluster.js:445:16) @ handleresponse (cluster.js:149:41) @ respond (cluster.js:170:5) @ handlemessage (cluster.js:180:5) @ process.eventemitter.emit (events.js:126:20) @ handlemessage (child_process.js:269:12) @ pipe.channel.onread (child_process.js:293:9)
you should use worker.suicide prevent calling .disconnect() multiple times:
if (!cluster.worker.suicide) { cluster.worker.disconnect(); } http://nodejs.org/api/cluster.html#cluster_worker_suicide
set calling .kill() or .disconnect(), until undefined.
Comments
Post a Comment