Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that stdout/stderr is properly flushed before exiting #382

Closed
wants to merge 4 commits into from
Closed

Ensure that stdout/stderr is properly flushed before exiting #382

wants to merge 4 commits into from

Conversation

dcherman
Copy link

In Windows, node currently does not properly flush the stderr/stdout streams before exiting when process.exit() is called. To work around that, we can ensure that those streams have been fully flushed prior to calling process.exit.

Related to one of the issues being discussed in cowboy/grunt#377

@dcherman
Copy link
Author

Any advice on how to test these changes? Like we saw with your simple test in IRC, the output that you can expect to get isn't really guaranteed or consistent between runs, so I'm not sure how I'd write tests against this that would give reliable/reproducible outcomes for these errors.

Current tests pass fully with the exception of 22 tests that you said are currently being worked on in the devel branch. I've built a couple projects locally with this without issues, and I may see about testing this on our CI server as well where this issue was very reproducible.

grunt.exit = function(code) {
// Since exiting in this manner is an asynchronous action, we need to first drain
// the action queue so that we don't improperly proceed to the next task.
while(grunt.task._queue.pop()){}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to just call grunt.task.clearQueue() here, see the relevant unit test.

@cowboy
Copy link
Member

cowboy commented Aug 26, 2012

It would be SO much easier if this was fixed upstream in Node.js.

@cowboy
Copy link
Member

cowboy commented Aug 26, 2012

I'm going to wait and see if they fix this in nodejs/node-v0.x-archive#3584

@cowboy cowboy closed this Aug 26, 2012
@cowboy
Copy link
Member

cowboy commented Aug 26, 2012

Also, in the short term, this can be worked around by piping grunt output to a temp file, eg:

grunt --no-color > %TEMP%\grunt & type %TEMP%\grunt & del %TEMP%\grunt

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

Successfully merging this pull request may close these issues.

2 participants