-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cluster IPC ERR_IPC_DISCONNECTED EPIPE #32106
Comments
this still occurs on the latest version, randomly running, only when more than 2 child processes |
error stack anonymous(), foo.js:21
emit(), events.js:316
anonymous(), worker.js:29
emit(), events.js:316
anonymous(), child_process.js:815
processTicksAndRejections(), task_queues.js:79
Async call from TickObject
init(), inspector_async_hook.js:25
emitInitNative(), async_hooks.js:144
emitInitScript(), async_hooks.js:346
nextTick(), task_queues.js:135
target._send(), child_process.js:815
target.send(), child_process.js:682
Worker.send(), worker.js:45
anonymous(), foo.js:26
emit(), events.js:316
anonymous(), master.js:214
onceWrapper(), events.js:422
emit(), events.js:316
finish(), child_process.js:866
processTicksAndRejections(), task_queues.js:79
Async call from TickObject
init(), inspector_async_hook.js:25
emitInitNative(), async_hooks.js:144
emitInitScript(), async_hooks.js:346
nextTick(), task_queues.js:135
target._disconnect(), child_process.js:877
target.disconnect(), child_process.js:848
channel.onread(), child_process.js:588
Async call from PIPEWRAP
init(), inspector_async_hook.js:25
emitInitNative(), async_hooks.js:144
anonymous(), child_process.js:963
getValidStdio(), child_process.js:927
ChildProcess.spawn(), child_process.js:341
spawn(), child_process.js:548
fork(), child_process.js:116
createWorkerProcess(), master.js:134
cluster.fork(), master.js:169
anonymous(), foo.js:9
Module._compile(), loader.js:1147
Module._extensions..js(), loader.js:1167
Module.load(), loader.js:996
Module._load(), loader.js:896
executeUserEntryPoint(), run_main.js:71
anonymous(), run_main_module.js:17 |
after reading the source code. I think the source of the problem is the Multithreading that child_process runs faster or slower than the main process with node 'use strict'
const cluster = require('cluster')
if (cluster.isMaster) {
const workers = []
let workerNum = 2
for (let i = 0; i < 2; i++) {
const worker = cluster.fork()
workers.push(worker)
worker.on('online', function () {
if (--workerNum === 0) {
for (const worker of workers) {
if (worker.isConnected()) {
console.log('send message die:', worker.id)
worker.send('die')
}
}
}
})
worker.on('disconnect', function () {
for (const worker of workers) {
if (worker.isConnected()) {
console.log('still connected', worker.id)
worker.send('die2')
}
}
})
}
} else {
process.on('message', function (msg) {
if (msg === 'die') {
console.log('get message die:', cluster.worker.id)
if (cluster.worker.isConnected()) {
cluster.worker.disconnect()
}
} else if (msg === 'die2') {
console.log('get message die2:', cluster.worker.id)
}
})
} output C:\Users\Himself65\Desktop\github\test>node example1.js
send message die: 1
send message die: 2
get message die: 1
still connected 2
get message die: 2
get message die2: 2 and we can see the second worker gets messages slower than the first worker. because |
Avoid sending multiple `exitedAfterDisconnect` messages when concurrently calling `disconnect()` and/or `destroy()` from the worker so `ERR_IPC_DISCONNECTED` errors are not generated. Fixes: nodejs#32106
Avoid sending multiple `exitedAfterDisconnect` messages when concurrently calling `disconnect()` and/or `destroy()` from the worker so `ERR_IPC_DISCONNECTED` errors are not generated. Fixes: #32106 PR-URL: #32793 Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Avoid sending multiple `exitedAfterDisconnect` messages when concurrently calling `disconnect()` and/or `destroy()` from the worker so `ERR_IPC_DISCONNECTED` errors are not generated. Fixes: #32106 PR-URL: #32793 Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Avoid sending multiple `exitedAfterDisconnect` messages when concurrently calling `disconnect()` and/or `destroy()` from the worker so `ERR_IPC_DISCONNECTED` errors are not generated. Fixes: #32106 PR-URL: #32793 Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Still able to recreate this issue with Node.js v14.16.1
Mitigation: To avoid uncaught exception cause service abort, add callback to capture the error
|
This is not production code.
Randomly generates errors:
node v12.15.0
Linux 5.5.6-201.fc31.x86_64
The text was updated successfully, but these errors were encountered: