Long-running processes crash with "Invalid string length"
Expected Behavior
I should be able to run a process that logs large amounts to stderr, as long as I don't need the full output as a single string at the end (for example, because it is already being piped or logged). To allow that, it's fine if it requires calling some extra method on $., it just should be possible.
Actual Behavior
Eventually, if the command outputs enough to stderr, the program crashes with
zx/build/core.js:172
combined += data;
^
RangeError: Invalid string length
The same can happen with stdout if the command is not piped, but stderr is unconditional, and there's nothing you can do to prevent it.
This happens because ZX is recording the entire stderr history (and stdout, if not piped) regardless of whether the caller will ever read that full output as a single unit. This eventually reaches the JS max string length and ZX will crash.
Steps to Reproduce the Problem
- Make a script that continuously logs to stderr
- Try to run that script via ZX
- No configuration of pipe / quiet / whatever will prevent ZX hitting the max string length
Specifications
- Version: 7.2.1
- Platform: Mac OS 13.4.1
True. Will work on some api to simplify this process.
Are there any workarounds for this? I have seen this issue a number of times now.