Skip to content

stdout not flushed on process.exit (Windows only) #504

Closed
queequac opened this Issue Nov 2, 2012 · 4 comments

3 participants

@queequac
queequac commented Nov 2, 2012

The subject is nearly the whole story and there is no problem while working from within the command shell only. But it leads to missing logs when the console output is redirected to other processes, such as IDEs.

For example I have integrated Grunt into Sublime Text 2 and Eclipse, so these can be used for writing JavaScript code. Grunt is simply an external build tool from the IDEs point of view and output is shown in a special console area.

I have been stumbling over several comparable issues, e.g. nodejs/node-v0.x-archive#3871 and satyr/coco#168

Anyhow, the issue is that process.exit() will terminate node immediately, even if there are still queued writes to stdout. A workaround would be to simply remove this call where possible.

In case of grunt this would be /lib/grunt.js (line 135) for successfull builds. ;-)
I am not sure if this explicit exit is really neccessary. If it is there just to be on the safe side, maybe it could be removed (at least under Windows) to make integration into 3rd party tools more reliable.
I have tested it, it really works by commenting out the line mentioned above.

But I have no idea how to handle failed builds (/lib/grunt/fail.js, lines 42 and 73), since the call to process.exit is required for errorcodes there. Maybe there is some way to explicitly flush stdout and stderr before exiting, but I could not figure out how...

Cheers, Roland

@cowboy
grunt member
cowboy commented Nov 2, 2012

I'm pretty sure I fixed this in 0.4.0 devel with 7f3c26b. Can you try 0.4.0a and see if that fixes the problem?

@queequac
queequac commented Nov 2, 2012

The new util.exit has correct stdout flushing, thanks for the fast reply! :+1:
Hopefully v0.4.0 will be released soon. ;-)

@queequac queequac closed this Nov 2, 2012
@matthiasg matthiasg referenced this issue in nodejs/node-v0.x-archive Nov 30, 2012
Closed

stdout not flushed upon exit with output redirect #1669

@matthiasg

@queequac i am having issues with regular node stdout flushing. what NEW util.exit where you talking about? Is this a util.exit in node.js or in grunt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.