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

Long-running processes crash with "Invalid string length" #650

Open
matthewvalentine opened this issue Jul 19, 2023 · 2 comments
Open

Long-running processes crash with "Invalid string length" #650

matthewvalentine opened this issue Jul 19, 2023 · 2 comments
Labels
feature New feature or request

Comments

@matthewvalentine
Copy link

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

  1. Make a script that continuously logs to stderr
  2. Try to run that script via ZX
  3. 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
@antonmedv antonmedv added the feature New feature or request label Jul 20, 2023
@antonmedv
Copy link
Collaborator

True. Will work on some api to simplify this process.

@schlenks
Copy link

schlenks commented Sep 8, 2023

Are there any workarounds for this? I have seen this issue a number of times now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants