Ensure error.bufferedData
is as full as possible
#106
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the stream is larger than
maxBuffer
, the last chunk is currently missing fromerror.bufferedData
, since it would makeerror.bufferedData
larger thanmaxBuffer
.This PR adds the last chunk instead, but truncated so it fits within
maxBuffer
.This has several advantages:
error
to help users debug the underlying issue.error.bufferedData
from being empty when a single chunk was emitted and it was larger thanmaxBuffer
. This can happen whenmaxBuffer
is low, or when the streamhighWatermark
is high.error.bufferedData
is always exactly the same. For example, I was trying Execa withget-stream@8
and the output ofchildProcess.stdout
was inconsistent between test runs, since the underlying stream's chunks are timing-dependent. Therefore, the test was harder to reproduce consistently.