Skip to content

fix(goods): handle stream read errors in responseToReadable - #1516

Open
swaraj792725 wants to merge 11 commits into
google:mainfrom
swaraj792725:fix/fetch-pipe-unhandled-rejection
Open

swaraj792725 wants to merge 11 commits into
google:mainfrom
swaraj792725:fix/fetch-pipe-unhandled-rejection

Conversation

@swaraj792725

Copy link
Copy Markdown

Fixes #1443

Description

In responseToReadable, the rs._read implementation calls await reader.read() without a try/catch block. When stream reading fails or is aborted (e.g., network disconnect or abort signal), the rejected promise is unhandled by Node's stream internals, resulting in an unhandled promise rejection process crash.

This PR wraps await reader.read() in a try/catch block and calls rs.destroy(err) when an error occurs, properly destroying the readable stream and allowing error handlers to catch it gracefully.

Testing

  • Added unit test in test/goods.test.ts verifying stream error handling in responseToReadable.
  • Also updated build scripts and test runners to use fileURLToPath from node:url for robust cross-platform path resolution when folder names contain spaces.

@google-cla

google-cla Bot commented Sep 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@swaraj792725

Copy link
Copy Markdown
Author

I have signed the Google CLA.

@swaraj792725

Copy link
Copy Markdown
Author

@googlebot I signed it!

@swaraj792725
swaraj792725 force-pushed the fix/fetch-pipe-unhandled-rejection branch from c5b140f to 3441eab Compare September 27, 2026 14:23

This branch has not been deployed

No deployments
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