-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
stderr and stdout interweave when written to different streams of the same file #9214
Comments
aaaarrrrrgggghhhh @ORESoftware what is stdout and stderr when this happens? a TTY (Terminal)? a Pipe? or a File? How large is the output? Has anything set See #6980 for this long stream of related and largely known problems. |
it's a terminal, but I have seen the same with files (.log files). And TMK nothing has set if I do this
then it seems to be much more consistent. whereas if I do this:
output in the log file then becomes inconsistent and messed up. I simply don't know how Node.js sets up stdout and stderr to write to the terminal, otherwise I could give you more info maybe. |
Interesting, so... that's a File, not a Terminal. I think I see what is going on though. cc @saghul ... creating two write streams seems to chunk and interleave to the same file. |
I'll do more investigation as to the exact trigger for this but that may take a day or two. |
The streams race each other unless UV_THREADPOOL_SIZE is set to 1. |
ok, I have a lead. this only seems to happen when I use Webstorm built-in terminal Webstorm highlights stderr as red. Maybe I can alert them of this problem. If I see it happen in a more standard terminal, will letchall know. |
What @bnoordhuis said is about as far as we'll get. If you use separate streams to the same file, they will race eachother and you'll get this. I think ensuring that writes are ordered though arbitrary piped streams is out of scope for node core. |
Ok, I have decided that this should be easy to fix :) My guess is that Webstorm's built-in IDE terminal is not a proper TTY, so what happens is that stdout and stderr don't block and therefore may interleave, according to the Node.js docs. So maybe the folks at Webstorm can somehow fake being a TTY or tell NodeJS that their built-in IDE terminal is a real TTY when it's not one. If you think this makes sense, then maybe we can move forward to help out Webstorm users. I have to say, built-in terminals are extremely useful, in my experience, I strongly prefer using IDEs over text editors for this reason more than any other. |
If webstorm has a terminal is needs to ensure that it makes that a pseudo tty, that is, it needs to look like a terminal to libuv. |
for sure, do you have quick links to create a pseudo TTY recognizable by Node.js / Libuv that I can share with Jetbrains so they can work on this? |
alrighty then :) |
On version 6.7.x of Node.js and a new Macbook
Always had this problem, where stderr and stdout mix in the terminal, like this:
(Stdout is black, and stderr is red)
I have noticed that if I do this:
then the streams don't get mixed up in the log file, since both stdout and stderr have to through the same stream before they get written, so I assume it creates more or less a single-file line before getting written out :)
Is there way to achieve that when running node how and perhaps putting stdout and stderr through the same bottleneck or something?
The text was updated successfully, but these errors were encountered: