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

[BUG] Piping non-ASCII output breaks console.log #324

Open
matheusb-comp opened this issue Apr 5, 2022 · 4 comments
Open

[BUG] Piping non-ASCII output breaks console.log #324

matheusb-comp opened this issue Apr 5, 2022 · 4 comments

Comments

@matheusb-comp
Copy link

matheusb-comp commented Apr 5, 2022

Detected this situation while running a code that prints a QR code to the terminal using qrcode-terminal.
It was using the small option, and checking the code, the lib seems to just print some unicode characters.

Example script:

const num = 15;
const char = '🐞';
[...Array(num)].forEach(() => console.log(char));
setInterval(() => console.log('A'), 1000);

When running this script piping the output (node index.js | pino-pretty), the higher num is, the longer it takes for the A logs to appear in the terminal, and when it happens, many of them are shown at once, instead of every second.

Running the code without piping to pino-pretty, or changing char to ASCII, like a dot (.), makes everything run normal again.

Environment

SO: Ubuntu 21.10 impish
Node: v17.2.0
pino-pretty: 7.6.0

@matheusb-comp matheusb-comp changed the title [BUG] Piping node output breaks console.log [BUG] Piping non-ASCII output breaks console.log Apr 5, 2022
@mcollina
Copy link
Member

mcollina commented Apr 6, 2022

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@matheusb-comp
Copy link
Author

Sorry, but I don't believe I have enough knowledge about stream transformation to send a PR to fix this.
I tried looking at the code and got confused about how it actually works.

As a workaround, I'm now using pino-pretty via programmatic integration, but using an environment variable to add the transport.target only in development.

@jsumners
Copy link
Member

jsumners commented Apr 6, 2022

This looks like a stream is buffering, but the defaults I see for the pino-pretty cli do not create a buffered stream?

@AntennaeVY

This comment was marked as abuse.

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

No branches or pull requests

4 participants