Skip to content

fix: catch errors in responseToReadable _read callback#1454

Open
alliasgher wants to merge 1 commit intogoogle:mainfrom
alliasgher:fix-fetch-pipe-unhandled-rejection
Open

fix: catch errors in responseToReadable _read callback#1454
alliasgher wants to merge 1 commit intogoogle:mainfrom
alliasgher:fix-fetch-pipe-unhandled-rejection

Conversation

@alliasgher
Copy link
Copy Markdown

Fixes #1443. The async _read callback in responseToReadable did not wrap reader.read() in a try/catch. If the reader throws (network error, abort, corrupted stream), the rejection was unhandled and could crash the process. Now caught and propagated via rs.destroy(err).

The async _read callback in responseToReadable did not wrap
reader.read() in a try/catch. If the reader throws (network
error, abort, corrupted stream), the rejection was unhandled
and could crash the process.

Catch the error and call rs.destroy(err) so downstream consumers
can handle it gracefully through the stream's error event.

Fixes google#1443

Signed-off-by: alliasgher <alliasgher123@gmail.com>
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.

[Bug]: Unhandled promise rejection in fetch().pipe() when response stream errors

1 participant