Version
22.2.0
Platform
Darwin MBP.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
Put this into repro.js
for(leti=0,l=1_000_000;i<l;i++){console.log(i);}process.exit();Then execute this, and notice how there's nothing to notice, it works like anybody would expect it to work:
Now execute this, and notice how the output is truncated for some reason:
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
The expected behavior is for that script to produce a consistent output. If the output is truncated just because we are piping it somewhere that doesn't really make sense to me.
According to the docs:
Calling process.exit() will force the process to exit as quickly as possible even if there are still asynchronous operations pending that have not yet completed fully, including I/O operations to process.stdout and process.stderr.
But I don't think anybody on the planet would want "output" to be truncated and not actually be logged when writing code like this:
console.log(output);process.exit();
Regardless of that, the output begin inconsistent depending on whether we are piping it to cat or not, considering that the script wants to log the same stuff no matter what, seems like a bug.
What do you see instead?
Inconsistent output depending on whether we are piping to cat or not.
Additional information
No response
Version
22.2.0
Platform
Darwin MBP.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
Put this into
repro.jsThen execute this, and notice how there's nothing to notice, it works like anybody would expect it to work:
Now execute this, and notice how the output is truncated for some reason:
node repro.js | catHow often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
The expected behavior is for that script to produce a consistent output. If the output is truncated just because we are piping it somewhere that doesn't really make sense to me.
According to the docs:
But I don't think anybody on the planet would want "output" to be truncated and not actually be logged when writing code like this:
Regardless of that, the output begin inconsistent depending on whether we are piping it to
cator not, considering that the script wants to log the same stuff no matter what, seems like a bug.What do you see instead?
Inconsistent output depending on whether we are piping to
cator not.Additional information
No response