You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constdoNothing=()=>{};process.stdin.on('data',doNothing);require('child_process').spawn('node',['-v']).on('exit',()=>{process.stdin.unref();console.log('After printing this, the process should exit');});
Run with node parent.js
Results
Linux: The process terminates by itself Mac: The process terminates by itself Windows: The process keeps running until Enter is pressed
This strange behavior seems to break some npm modules.
Other details
Adding process.stdin.removeListener('data', doNothing)
or process.stdin.removeAllListeners('data')
before unref doesn't make any difference.
When enter is pressed, it doesn't trigger data callback, just terminates the process.
Edit
Simplified code:
// parent.jsprocess.stdin.on('data',()=>{});setTimeout(()=>{process.stdin.unref();console.log('After printing this, the process should exit');});
Here we don't have a child process. Run with node parent.js
Results on windows
50% of times - the process exits
50% of times - the process keeps running
That most likely means that the streams implementation for Windows does not clean up fully when uv_close() is used without an extra uv_read_stop() that precedes it.
We can revert #21528 without any issues, but the real issue is almost certainly a libuv one.
Activity
lovinglyy commentedon Sep 22, 2018
The simplified code is always working fine for me, the first one I can reproduce that it's needed to press
enteron Windows. Node v10.10.0 also.bzoz commentedon Sep 24, 2018
Can reproduce with v10, does not reproduce with v8.
bzoz commentedon Sep 25, 2018
This is caused by #21528
/cc @addaleax
addaleax commentedon Sep 25, 2018
That most likely means that the streams implementation for Windows does not clean up fully when
uv_close()is used without an extrauv_read_stop()that precedes it.We can revert #21528 without any issues, but the real issue is almost certainly a libuv one.
bzoz commentedon Sep 26, 2018
Ok, its a libuv bug. I have a fix, I will open a PR with a fix soon.
win, tty: fix uv_tty_close
bzoz commentedon Sep 27, 2018
Fix in libuv/libuv#2005
cjihrig commentedon Sep 30, 2018
Reopening until the next libuv update.
deps: upgrade to libuv 1.23.2
deps: upgrade to libuv 1.23.2
deps: upgrade to libuv 1.23.2
win,tty: fix uv_tty_close()
fix(hooks): exit explicitly after writing the response (Windows orpha…
deps: upgrade to libuv 1.23.2