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

Standard out sometimes failing to output *before* error/exception for node-v0.10.3-x64 #5275

Closed
fresheneesz opened this issue Apr 11, 2013 · 5 comments

Comments

@fresheneesz
Copy link

I've come across this issue in a few places while experimenting with nodejs the past few days. The issue is pretty simple and is documented here:

http://stackoverflow.com/questions/15937266/nodejs-console-log-not-writing-before-error

@bnoordhuis
Copy link
Member

This sounds like a dup of #3584.

@fresheneesz
Copy link
Author

Looks likely. I am on windows.

@fresheneesz
Copy link
Author

Note that the following does not cause this problem:

Looks like someone submitted a fix. I'm working around it by using this function:

var fs = require('fs');
function log(m) {
  fs.writeSync(process.stdout.fd, m+"\n");
};

log("test");
log("test");
throw Error("test");

Perhaps the fix is simply to implement console.log and the like using this kind of file descriptor writing mechanism

@bnoordhuis
Copy link
Member

Perhaps the fix is simply to implement console.log and the like using this kind of file descriptor writing mechanism

Well, console.log and friends are already supposed to be blocking iff stdout/stderr is a tty or a file (but not a pipe to another process.) If you're seeing - or rather, not seeing - dropped messages, that means something is not working as expected.

@jasnell
Copy link
Member

jasnell commented May 26, 2015

Appears to have been fixed.

@jasnell jasnell closed this as completed May 26, 2015
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

3 participants