Open bzoz opened 6 years ago
Try to investigate why this happens these days:
process.disconnect()
, a child process will call process.exit()
to exit automatically. process.send()
will firstly call uv_try_write
and expect it's done immediately. If it's done asynchronously, the process will exit before callbacks are called. https://github.com/nodejs/node/blob/af7164ebccd21d9fc5b0782e0427257f7637a4db/src/stream_wrap.cc#L303
uv_try_write
for pipes is not implemented on Windows and it will always return EAGAIN
. So that on Windows the callback won't be call if it exit
s immediately. (libuv code here)I also found that @bnoordhuis had a PR before to implement uv_try_write
for pipes but it didn't land finally.
I think implementing uv_try_write
for pipes on Windows is the most elegant way to solve this issue if possible. Otherwise, we may need to prevent child process exit by calling procecss.exit()
directly.
net.js
and http2.js
might have the same problem on Windows as they also call uv_try_write
.
On Windows, after calling
process.disconnect
callbacks for previousprocess.send
calls are not called. Example:On Windows this will print:
whereas on Linux it will print
This was reported in https://github.com/libuv/libuv/issues/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:
On Windows this will print:
and on Linux:
/cc @nodejs/platform-windows @nodejs/cluster