Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Stdout output is not completely flushed upon process exit. #8329

Closed
juj opened this issue Sep 7, 2014 · 16 comments
Closed

Stdout output is not completely flushed upon process exit. #8329

juj opened this issue Sep 7, 2014 · 16 comments

Comments

@juj
Copy link

juj commented Sep 7, 2014

I've tried to follow the trail of existing issues in the tracker to deduce whether this is still actively tracked/reported, but was not quite able to. The issues #1669, #3584, #3479, #5275 all relate to this, but are either closed or not exactly this one, so I'm reporting this as a new issue.

If the output of node.js is piped to another application, then the receiving application might not get the whole output when node.js terminates.

Steps to repro:

  1. Have python and node.js installed and in PATH.
  2. Download and unzip http://clb.demon.fi/bugs/nodejs_flush_bug.zip
  3. Run run_test.bat

Observed: The printed output differs on the two cases printed by the test, i.e. the second case does not print "Line 2".

Expected: The output should read identical result in both cases, i.e. "Line 2" should be printed out on the second run as well.

@juj
Copy link
Author

juj commented Sep 7, 2014

Tested that this occurs in node.js v0.10.31. Based on the experience from running unit test bot farm on Windows, Linux and OSX, it looks like that this is a Windows-only bug at this point.

@juj
Copy link
Author

juj commented Sep 7, 2014

Currently the best workaround we have found is this set of commits:

@tracker1
Copy link

tracker1 commented Sep 8, 2014

If you're using console.log output is async, and buffered, which may not flush before exit... warn/error are not async/buffered..

It may be disirable to flush the output... I usially wrap my process exits in a process.nextTick to avoid/reduce the issue.

@Offirmo
Copy link

Offirmo commented Sep 12, 2014

Hello, this is not a windows-only issue. I have the problem on linux with foreman.

This was reported using foreman for another user : ddollar/foreman#440 (see the proposed solution wich is no longer usable)

This problem has triggered using the creation of dedicated modules : https://www.npmjs.org/package/exit (it works [still experimenting] for my foreman config in node 10.31)

Hope this helps...

@cowwoc
Copy link

cowwoc commented Jan 23, 2015

What is the status of this bug? #3584 makes me believe this was fixed, but the conversation is quite long with fixes merged and unmerged along the way. What is the final status?

If this issue is fixed, what version is the fix merged into? And should this issue be closed?

@juj
Copy link
Author

juj commented Jan 23, 2015

I believe the issue still exists. I ran into it about 5 months ago, and I haven't found a set of commits since then that would have fixed it.

@cowwoc
Copy link

cowwoc commented Jan 23, 2015

@juj This is supposed to be fixed as of 0.11.15. See 20176a9

Did you test a version newer than that?

@tjenkinson
Copy link

I can confirm I was having this issue on windows with nodejs v0.10.32 and this issue has now gone with v0.12.2 :)

@jasnell
Copy link
Member

jasnell commented Jun 25, 2015

@misterdjules ... are you familiar with this one? Wondering if this is one we should backport to v0.10

@myndzi
Copy link

myndzi commented Jul 9, 2015

This affects me on 0.12.6 and has for some time. It's pretty irritating, makes it complicated to dump large objects and exit, and can screw up the prompt from the result of a test reporter with long output that gets interrupted before it can reset colors.

@tracker1
Copy link

FYI: for those interested, if you use console.error, the output gets serialized... I also notice if I do a process.nextTick before exiting my ouput makes it through.

@danielbprice
Copy link

We just upgraded our codebase from node 0.10.40 to 0.12.7. We dump a large JSON structure to stdout on a TTY, and in some cases a python-expect script doing validation tries to grab that (yes, I know, I know). While things were stable and worked 100% reliably on 0.10.40, this has regressed exactly as described above by @myndzi and @tracker1 in 0.12.7. I should say we're using Linux.

@ioncube
Copy link

ioncube commented Mar 4, 2016

Just came across what seems to be the same issue when testing remarkable. Occurs with 0.12.10 and 5.7.1. Piping into cat displays full output while displaying direct to a tty almost always truncates.

@mikemaccana
Copy link

Anyone else getting this on node 4.x.x?

@eljefedelrodeodeljefe
Copy link

I am closing this in favor for nodejs/node#6456 and a respective PR nodejs/node#6773. The issue is very complex, widespread, not very clear defined and we are working on a fix / feature addition to aid this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests