sindresorhus / get-stream

Get a stream as a string, Buffer, ArrayBuffer or array
MIT License
341 stars 33 forks source link

`error.bufferedData` is missing in `7.0.0` (except on `maxBuffer` error) #56

Closed ehmicky closed 1 year ago

ehmicky commented 1 year ago

Before 7.0.0, when the stream errored, the currently buffered data would be available as error.bufferedData. Since 7.0.0, this is not the case anymore, except when maxBuffer is hit.

Re-adding this feature should be fairly simple and non-breaking, since the data is already being buffered in the code, i.e. we'd only need to add a try/catch handler that sets error.bufferedData = getBufferedValue(). I'm happy to submit a PR if that sounds good.

This issue is preventing Execa from upgrading get-stream from v6 to v7. This is because Execa sets error.stdout, error.stderr and error.all using the logic described above.

https://github.com/sindresorhus/execa/blob/65992b418816b965d2e3f89b44d3c259ecd0c99a/lib/stream.js#L75-L89

sindresorhus commented 1 year ago

Sounds good. It was just an oversight. PR welcome :)

ehmicky commented 1 year ago

Done at #63.