-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
process.stderr.write message is not displayed if it does not contain a newline #5005
Comments
This is probably due to nodejs/node#6456 which seems to have a long-standing history in Node land, ever since they made stdio async (v6). |
@kuzyn if you are in a position where you can reproduce this consistently, could you try this code and see if it works? (I can't reproduce it on Node v8.5.0 on OSX, even using test examples from the above nodejs issue)
The 2nd argument can be a callback that is called after the data is flushed, so we should be able to delay exit until that happens. This is supported in Node v4 which IIRC is as far back as Yarn supports. Docs reference: https://nodejs.org/dist/latest-v4.x/docs/api/stream.html#stream_writable_write_chunk_encoding_callback |
NPM seems to work because they log through the npmlog module which according to the README:
This blocking stdio approach is not recommended by the Node team (in the comments of the node issue I linked above) "If possible don't do .handle.setBlocking, since this will affect the whole process" however it is listed as the "temporary workaround" at the top if that issue as well. I guess that gives us a way to fix this if the above "write with callback" doesn't work. |
Thanks for the info/research! The callback is indeed more elegant anyway. I'll check if I can reproduce with w/r/t the stdout being non-blocking on osx/linux, this make sense as I can reproduce (from my linked test-yarn repo) on arch (4.13.4-1) with node |
Weird. I tried it in Well since you can reproduce it @kuzyn do you want to make a PR to fix it? I would try adding the recommended fix from the node issue linked above to the entry file of Yarn, which is This code should work and pass Flow and linting:
Or put that code in a separate function that I appreciate the help! |
@rally25rs Yeah, looks straightforward enough; I'll have a shot at it 👍 |
The fix does not seem to work with node And after reading through this joyent repo and issue nodejs/node#6297 and nodejs/node#6379 I am not even sure if this temporary fix should be applied anymore. What do you think @rally25rs ? |
Lovely 😢 Interestingly, that
but I read somewhere that you have to call Going back and re-reading this issue from the top, I'm starting to wonder if this is because of I had been thinking it was Yarn's logging itself that wasn't writing out, but it might just be the stdio from that child process never being flushed... Let me see if I can rig up a way to reproduce that... |
OK, now I'm even more confused... I can reproduce the issue now 🎉 But looking at the Yarn code, it looks like we set What's weird though is that when Yarn prints the error itself to stdio "error Command failed with exit code 1." that output is there and should be on the same stream as the rest of the (missing) output. So how did it print some output, then skip some, then output some more, when they are all (i think) I started digging through the NPM code to see what they do differently, and I think they set the |
Oh hey! I figured it out! 🎉 After like an hour of tracing back through the code, I found this in
It turns out on reporter writes, we clear the current output line! This is why adding a It looks like every call to
It looks like it deletes any stdio output that was written before the call to |
I had a similar issue on a project of mine. The last line in any log was always removed. Adding a termincal cursor ( |
@rally25rs @bestander: Not to be pushy, but is a fix for this on the roadmap? I just rediscovered this issue for the second time (via #5030). Thanks! |
@LandonSchropp sorry for the slow reply. was out at a conference for a week, then had offsite meetings at work the week right after 😑 ... There is a major code update on the way (next major version) that might fix this (I haven't see the new code to know) but otherwise no, I sorta forgot about it since I was hoping for a reply from Kittens. Or maybe @arcanis knows something about the original intent of |
This is still an issue in v1.22.10. |
This is still happening, and there are cases where I need to inherit the output so I don't have a way to add a newline |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Both
npm start
andnode index.js
display theprocess.stderr.write
message in this handler, but notyarn start
For it to display when using
yarn start
, one needs to add a\n
to the template literateMore precisely, everything up until the newline will be flush to the buffer, so if the
\n
is in the middle, everything before will be shownIf the current behavior is a bug, please provide the steps to reproduce.
https://github.com/kuzyn/test-yarn
What is the expected behavior?
The
process.stderr.write
message should be displayed regardless of the presence of a newline characterPlease mention your node.js, yarn and operating system version.
The text was updated successfully, but these errors were encountered: