#55618: fix: reject net.fetch when upload body stream errors
Merged
Description of Change
Fixes #55372.
In lib/browser/api/net-fetch.ts, req.body.pipeTo(...) was invoked without a .catch() rejection handler. When a ReadableStream upload body errors or is cancelled mid-stream:
- An unhandled promise rejection (
ERR_UNHANDLED_REJECTION) was emitted. - The outer
net.fetchpromise never resolved or rejected, leaving the caller hanging indefinitely. - The underlying
ClientRequestwas never aborted.
This change attaches a .catch() handler to pipeTo(...) that marks locallyAborted = true, calls r.abort(), and rejects the fetch promise with the stream error.
Added regression tests in spec/api-net.spec.ts verifying that net.fetch aborts and rejects when upload body streams encounter an error or are cancelled mid-stream.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - tests are changed or added
- PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, past tense, and no longer than 80 characters.
Release Notes
Notes: Fixed unhandled rejection and hang in net.fetch on upload stream error.
Backports
Semver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron