Open
Description
- Version: 9.6.0
- Platform: Windows
- Subsystem: cluster
On Windows, after calling process.disconnect
callbacks for previous process.send
calls are not called. Example:
'use strict';
const cluster = require('cluster');
if (cluster.isMaster) {
cluster.fork().on('message', (msg) => {
console.log(msg.msg);
});
} else {
process.send({msg: 'hello'}, () => {
console.log('cb!');
});
process.disconnect();
}
On Windows this will print:
hello
whereas on Linux it will print
hello
cb!
This was reported in libuv/libuv#1729, but it looks like some issue with cluster module. Callbacks are called on both platforms in the following code, which uses bare IPC pipe:
const cp = require('child_process');
if (process.argv[2] === 'child') {
process.send({msg: 'hello'}, () => {
console.log('cb!');
});
process.disconnect();
} else {
const child = cp.spawn(process.argv0, [__filename, 'child'], {
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
});
child.on('message', (msg) => {
console.log(msg.msg);
})
}
On Windows this will print:
hello
cb!
and on Linux:
cb!
hello
/cc @nodejs/platform-windows @nodejs/cluster