fix(install): retry truncated downloads in HttpClient::get_bytes#1940
Merged
fengmk2 merged 2 commits intoJun 25, 2026
Merged
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
83fb362 to
6eb6a31
Compare
Member
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
fengmk2
approved these changes
Jun 25, 2026
…in_httpclient_get_bytes
Member
|
@shulaoda Nice job! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
HttpClient::get_bytesread the response body (response.bytes().await) outside the retry. The retry only wrapped request setup (send().await?.error_for_status()), which resolves as soon as the response headers arrive — so a connection dropped mid-body (a response truncated relative to its advertisedContent-Length) surfaced as a hard error that was never retried.download_filealready handles this by streaming the body inside its retry and checkingContent-Length.get_bytesis the download path for the platform tarball in:vp upgrade—crates/vite_global_cli/src/commands/upgradecrates/vite_installerSo a transient mid-body drop (flaky wifi, a proxy/CDN closing the connection early) failed the upgrade/install outright with
… end of file before message length reached, even though a single retry would usually succeed. Node-runtime and package-manager tarball downloads (which go throughdownload_file) already retried.Fix
Read the body inside the retried closure — one send+body unit, mirroring
download_file— so a mid-body drop is retried. The now-unused privateget/get_with_accepthelpers are removed (get_with_acceptwas only ever called withaccept = None).Test
test_get_bytes_retries_on_truncated_body: a rawtokioTCP server truncates the first response (advertises the fullContent-Length, sends half the body, drops the connection) and serves the full body on the retry. Against the old code it fails with hyperIncompleteBodyafter 1 attempt; with the fix it succeeds after 2.Reproduce end-to-end with
vp upgradeA mock registry truncates the platform tarball on every request. The fixed
get_bytesretries (4 tarball hits); the old one gives up after 1.Watch terminal A's
[tarball] hit #N:hit #1 #2 #3 #4— retriedFailed to download platform package: … end of file before message length reachedhit #1— no retryBoth end with the same error (the mock always truncates); the hit count is the difference — on a real flaky network the retry usually succeeds on attempt 2–4.
mock-registry.js🤖 Generated with Claude Code