Skip to content

Add error.isMaxBuffer #963

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

Merged
merged 1 commit into from
Apr 7, 2024
Merged

Add error.isMaxBuffer #963

merged 1 commit into from
Apr 7, 2024

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Apr 7, 2024

This adds error.isMaxBuffer: boolean. This is true when the subprocess failed due to the maxBuffer option.

Figuring out whether the subprocess failed due to the maxBuffer option is not completely straightforward otherwise:

  • execa() fails with MaxBufferError instances (which Execa does not export)
  • execaSync() fails with error.code ENOBUFS. However that code is also used for other errors by Node.js.

Also, this PR improves the error message when maxBuffer is hit. Previously, it just showed maxBuffer exceeded. Now, the error message is clearer. Also, it indicates:

  • Which stream was too big: stdout, stderr, stdio[3], etc.
  • The maxBuffer value
  • The unit: bytes, characters, lines or objects

@ehmicky ehmicky force-pushed the error-is-max-buffer branch from 5f2dd70 to 5734fd0 Compare April 7, 2024 15:56
@ehmicky
Copy link
Collaborator Author

ehmicky commented Apr 7, 2024

Fixed merge conflict.

@sindresorhus sindresorhus merged commit 9e6e19e into main Apr 7, 2024
12 checks passed
@sindresorhus sindresorhus deleted the error-is-max-buffer branch April 7, 2024 16:54
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

Successfully merging this pull request may close these issues.

None yet

2 participants