You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't think this is a Node.js problem itself, but the underlying OS rules.
The pipe buffer is simply full by its first read.
As you may see, Node.js requests 288.895bytes write into stdout. Only 65.536 (64kib) were written. As the event loop is done, Node.js will simply exit.
If you decide to use streams instead, your loop will be busy waiting for the "drain" event. So $ node -e 'require("fs").createReadStream("/tmp/file").pipe(process.stdout)' | c at will fix your issue.
I can't reproduce with node -p 'Array.from({length:5000}, (_, i) => i + 1).join(" ")' | cat, it outputs all the numbers for me
Try 50000.
Your're simply overflowing the pipe buffer.
Node is, not me :D
Simply doing node -e 'process.stdout.write(require("fs").readFileSync("file", "utf-8"))' resolves it for me. So, I'm not sure what -p is doing differently.
Activity
aduh95 commentedon Jan 10, 2026
I can't reproduce with
node -p 'Array.from({length:5000}, (_, i) => i + 1).join(" ")' | cat, it outputs all the numbers for mejuanarbol commentedon Jan 10, 2026
I don't think this is a Node.js problem itself, but the underlying OS rules.
The pipe buffer is simply full by its first read.
As you may see, Node.js requests 288.895bytes write into stdout. Only 65.536 (64kib) were written. As the event loop is done, Node.js will simply exit.
If you decide to use streams instead, your loop will be busy waiting for the "drain" event. So
$ node -e 'require("fs").createReadStream("/tmp/file").pipe(process.stdout)' | c atwill fix your issue.It just prints everything. The loop is gonna wait for the buffer to drain. And write again, and again... until done.
Or doing more weird stuff like "waiting for drain", will fix your issue.
$ node -e 'const d=require("fs").readFileSync("/tmp/file"); if(!process.stdout.write(d)) process.stdout.once("drain", () => {});' | catYour're simply overflowing the pipe buffer.
juanarbol commentedon Jan 10, 2026
It works nicely in
24.6BTWmohd-akram commentedon Jan 10, 2026
Try 50000.
Node is, not me :D
Simply doing
node -e 'process.stdout.write(require("fs").readFileSync("file", "utf-8"))'resolves it for me. So, I'm not sure what-pis doing differently.mohd-akram commentedon Jan 10, 2026
Didn't work for me. But Node.js 20.19.6 behaves correctly.
juanarbol commentedon Jan 10, 2026
I meant macOS version.
I honestly don't have too much more to say about this issue. This may helps a bit v24.12.0...v20.19.6
mohd-akram commentedon Jan 11, 2026
Might be this - a8b21fd (#52172)
The problem happens from 22.0 onwards. Maybe a synchronous print needs to happen there (or use the
beforeExitevent).process: do not truncate long strings in `--print`
process: do not truncate long strings in `--print`
process: do not truncate long strings in `--print`
process: do not truncate long strings in `--print`
process: do not truncate long strings in `--print`