-
Notifications
You must be signed in to change notification settings - Fork 7.3k
console.error output not always flushed before process.exit #3479
Comments
Seems to work for me. Can you retest it with v0.8? By the way, it's better to use |
Have just installed and tried v0.8.0 (node --version result). Gives the same output (three empty lines after the Error: line). From cmd.exe:
In the real code, the outer script is a test runner, which is why the 'node' was explicit. But you're right, if it is running, it doesn't need to test whether 'node' can be found:-) |
@piscisaureus You should probably look at this, I can't reproduce it. |
I get the same as @clausreinke with v0.8 |
This is a particular behaviour of windows. When a pipe is closed all data that has been sent, but has not been read yet by the other end, is discarded. When a process exits it's pipe end is closed immediately. Normally libuv works around this issue, but when process.exit() is called libuv doesn't get the chance to do anything about it. |
Closing, tracking in #3584. |
Thanks for the info. So do I understand correctly that the data has been written, as far as the child process is concerned, but gets killed in transit when the child breaks the pipe on exit? Does that mean my workaround only works by accident, or does it profit from those libuv workarounds? In any case, could this information be added to a portability issues section in the nodejs docs, with suggested workarounds? |
I have a simple node script that uses exec to run node scripts.
After adding process.exit(1) calls to the child, its console.error output sometimes goes missing.
Note that calling the child code directly shows the stderr output, while calling the
child via .exec loses the child's stderr output.
Note that calling another failing sub-process does not lose stderr output:
Uncommenting the console.log line sometimes outputs both stdout and stderr, sometimes still none.
All of this is on windows, in an msys shell.
As a workaround, replacing
with
seems to work.
The text was updated successfully, but these errors were encountered: