#55439: perf: skip the upload stream adapter for net.fetch() requests without a body
Description of Change
net.fetch() wraps every outgoing request in Writable.toWeb() so that it can pipe the request body into it, even when there's no body to send. Writable.toWeb() has a measurable per-call cost, so this PR only calls it when there's a body.
This is one of three independent PRs that speed up protocol.handle() handlers that serve local files with net.fetch(), which is how VS Code serves vscode-file: (microsoft/vscode#341401). #55437 does most of the work by answering local file: fetches without the URL loader, and #55438 speeds up the file: fetches that still use it. This one helps every bodiless net.fetch() that goes through the URL loader, on any scheme.
| VS Code workbench load | main |
this PR | all three PRs |
|---|---|---|---|
| with VS Code's webRequest listeners | 2694 ms | 2571 ms (−5%) | 1164 ms (−57%) |
| without listeners | 1880 ms | 1826 ms (−3%) | 1110 ms (−41%) |
Medians of 10 interleaved runs on Linux with a non-official release build, replaying VS Code's workbench load: 4,831 requests through VS Code's own vscode-file: handler. The full benchmark notes, written for agents, are here.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
- 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.
🤖 Generated with Claude Code
Release Notes
Notes: Improved performance of net.fetch() requests without a body.
Backports
Semver Impact
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