このエラーはどこで/いつキャッチする必要がありますか?
Error: IPC channel is already disconnected
これは、複数回呼び出すとchild_process
(using cluster
) モジュールから呼び出されます。.disconect()
これを 2 回 (またはそれ以上) 呼び出すべきではないことはわかっていますが、これを制御できない場合があります。最終的にこれを複数回呼び出すのを防ぐ方法は? このコードは機能しません:
try {
if (worker.state !== "disconnected" && worker.state !== "dead") {
worker.disconnect();
}
} catch (error) {}
編集:
これは、このエラーのスタック トレースです。
events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: IPC channel is already disconnected
at process.target.disconnect (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 Pipe.channel.onread (child_process.js:293:9)