-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
fix unicode problems with verbose log #1165
Conversation
Hi @IIIMADDINIII, Which character encoding are you using in Powershell? The write needs to happen synchronously. Otherwise lines might be out-of-order. For example, in verbose mode, the command needs to be printed before its output. When the write is done asynchronously, there is a chance the subprocess Unfortunately, Now it does seem that But whatever the solution is, it needs to guarantee that logs are printed in order. This PR would break this for the other users. |
I Use UTF8:
I Understand that the output of logs need to stay in order. Looking through the NodeJs Sources it seems that process.stderr.write is sync as long it is pointing to console on windows. I also tried to call Would it be ok to only use process.stderr.write when running under windows and process.stderr.isTTY returns true? |
Thanks for looking deeper into this.
The Node.js documentation seems to indicate the opposite.
Lines being printed out-of-order happens on a race condition. In most cases, it actually does not happen. We only found out the problem in the automated tests since they are running hundreds of tests at once, which creates some contention on the Also, since verbose logs always print on The original PR and issue for this problem: #600, #598 For example, the following might reproduce it, if some command line like import {execa} from 'execa';
await Promise.all(Array.from({length: 1000}, (_, index) =>
execa({verbose: 'full', stdout: 'inherit'})`node -p ${index}`));
Going to the original problem, it does look to me there might some character encoding problem there. That being said, it's also very possible that the problem is due to It can be argued that writing weird characters on some Windows setup is a bigger problem than printing the command line before the first |
I just learned some new stuff. Powershell has more than one encoding setting. The tests in #600 use a pipe and not tty to write the data. so my proposed change would not influence this. I understand if you do not want to merge this solution because it is a bit hacky. |
I should have checked this one too! I actually used to write about this.
Also, our test runner Ava is actually not running in a TTY ( Thanks for all this additional work. We actually do not have a specific automated test (despite have 5000 of them :) ) that ensures verbose logs are never printed out-of-order. We were just relying on the fact that some automated tests used to randomly fail. I just tried adding such a test, and it made me realize using synchronous I/O (through Unfortunately, that means this out-of-order problem is still there, but we haven't received any bug report about it so far, so I guess its race condition only triggers under very specific circumstances (such as running lots of subprocesses in parallel at once, while using both |
I tested #1167 on my system, and it works as expected. |
Running under Windows 11 and using Powershell i noticed, that unicode characters are not displayed correctly when using verbose logging.
For example the "✔" Symbol for the verbose doen message is displayed like "Ô£ö" on my system.
I noticed in the NodeJs Source code that process.stderr.write and writeFileSync are using different subsystems and it seems that writeFileSync is not playing nicely with terminals.
This Pull Request fixes the Problem for me.