Repository navigation
perf(upgrade): download release assets over parallel ranges - #381
Conversation
release-assets.githubusercontent.com throttles each connection on some networks. The 9.6 MB darwin_arm64 archive took 122-171 s over one connection but 25 s as 8 ranges, each on its own connection, with an identical checksum. `skillshare upgrade` and the first `skillshare ui` of a new version both waited minutes on that download. DownloadToFile probes with `Range: bytes=0-0`; a 206 answer splits the file into ranges fetched in parallel from the redirected URL, and a 200 answer streams the single response as before, so servers without range support cost no extra request. Size limits and checksum verification are unchanged. The UI asset download is about 2 MB now, so the docs no longer say 1 MB.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bfe3729f26
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| transport := http.DefaultTransport.(*http.Transport).Clone() | ||
| defer transport.CloseIdleConnections() | ||
| client := &http.Client{Timeout: timeout, Transport: transport} |
There was a problem hiding this comment.
Preserve the supplied client's transport for range requests
When the provided client uses a custom transport—for example, a private CA, authenticated proxy, or custom dialer—the probe succeeds through that transport, but every parallel request is rebuilt from http.DefaultTransport. Those requests then bypass the caller's network configuration and can fail even though the initial request succeeded; clone the supplied *http.Transport (or otherwise preserve the client's request behavior) while still creating distinct connections.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 22d76ee. Each range now copies the caller's client with a clone of its *http.Transport (rangeClient), so a private CA, proxy or custom dialer applies to every range while each range still gets its own connection; a transport that is not an *http.Transport is shared as is. Covered by TestDownloadToFile_RangesKeepTheClientTransport, which downloads from an httptest.NewTLSServer with srv.Client() and failed before the fix with x509: certificate signed by unknown authority.
Each range built its client from http.DefaultTransport, so a caller's custom transport (private CA, authenticated proxy, custom dialer) only applied to the probe. The ranges then failed or bypassed the caller's network setup even though the probe succeeded. Each range now copies the caller's client with a clone of its *http.Transport, which keeps those settings and still gives the range its own connection. A transport that cannot be cloned is shared as is.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 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". |
Type
perf)proposals/only — see CONTRIBUTING.md)Linked Issue
None. Found while the desktop app's CLI upgrade took 3+ minutes.
Summary
release-assets.githubusercontent.comthrottles each connection on some networks (~80 KB/s here, while Cloudflare/npm serve 10 MB in 0.4 s).skillshare upgradeand the firstskillshare uiof a new version both waited minutes on it.utils.DownloadToFile: probes withRange: bytes=0-0. A 206 answer → 8 ranges in parallel from the redirected URL, each with its own connection (a shared HTTP/2 connection stayed throttled: 97 s), written withio.NewOffsetWriter, exact byte counts checked; the first error cancels the rest. A 200 answer streams that response as before (no extra request). Size limit enforced before downloading.downloadArchive(upgrade) anduidist.downloadToTempuse it. Checksum verification unchanged.Timing (devcontainer,
skillshare_0.24.1_darwin_arm64.tar.gz, 9,665,580 B): single connection 170.7 s → 8 ranges 25.0 s; sha256 matcheschecksums.txtboth ways.Checklist
make check) — 4 tests ininternal/utils/download_test.go(ranged reassembly, no-range fallback, failed range, oversize); fullmake checkpassed in the devcontainer;go test -race ./internal/utils/passedNot run: website build, E2E runbooks.