#5572: since 80a47abba a silent download is broken off after 30s and
tried again, but the update's download still had a 10-minute total
(the update client's Timeout, the GUI run's ctx, `magpie update`'s ctx).
A download under ~140 KB/s, still receiving bytes, failed the 83 MB
Windows exe at 10 minutes part way. The stall timer is what ends a dead
one now; nothing ends one that is still moving.
- internal/update: fetch downloads through fileClient, the client without
its Timeout. The feed and notes keep the 10-minute client. fetch's stall
timer runs from the ask to the last byte, so a server that never answers
still ends at stallAfter (30s), and download's retries stay bounded
(len(retryWaits)+1 = 6 tries), so a connection that keeps going silent
ends in about 4 minutes.
- internal/gui (Mac Stage, Windows/Linux StageBinary): run's 10 minutes
(checkWait, a var for tests) bound only LatestIn; the download runs
under a ctx with no deadline.
- internal/cli `magpie update` (Mac Stage, Windows/Linux ReplaceBinary):
the same split.
- Siblings with the same fixed cap:
- new internal/stall: Start(ctx, after) gives a ctx that ends with
ErrStalled once `after` goes by with no byte read through w.Reader.
- Bun (internal/plugin getURLOnce): watched with a 60s stall;
KeepBunUpdated's 10-minute ctx around CheckBun is gone.
- Claude Code (internal/claudecode downloadOnce, ~200 MB): watched with
a 60s stall; keepOnce's 30-minute ctx around install is gone.
- pf-serve (internal/pii upgrade): its 10-minute ctx is gone; get
already had a 60s stall and the client a 60s header timeout, as the
model's download (no total) does.
- Left as they are: plugin installs and npm updates (KeepUpdated's 10
minutes) run `bun install`, whose network is Bun's own, small tarballs;
rtk (5 min client), skills (2 min client), skilltree and market reads
are small files; Grok CLI install has no cap of its own (its caller's
ctx). None of them carries a large download behind a wall-clock total.
Run on mote (mote-run), at 49f207c78 + this change; the targeted
set again after rebasing on d4a221f79 (ok):
- go test ./internal/stall ./internal/update ./internal/claudecode
./internal/pii -run 'Stall|Slow|Silen|TestDownload|TestInstall|TestKeep';
go test ./internal/plugin -run Bun; go test ./internal/gui -run
TestUpdate: ok
- new: TestSlowButMovingIsReadWhole, TestSilenceIsAStall (no answer, part
way), TestDownloadSlowButMovingOutlastsTheClientTimeout (client Timeout
300ms, body ~1.2s: one try, no retry), TestUpdateSlowDownloadOutlastsTheCheckBound
(checkWait 200ms, body ~600ms: ready), TestDownloadThatGoesSilentIsAStall
(claudecode), TestBunDownloadThatGoesSilentIsAStall. The silent server
after its retries stays covered by TestDownloadStallEveryTimeSaysSo
(6 tries, errStalled).
- go test -race -count=3 ./internal/stall ./internal/update -run
'Stall|Slow|Silen': ok
- win-run (Windows 11): ./internal/stall ./internal/update
./internal/claudecode ./internal/plugin with the same -run, and
./internal/gui -run 'TestUpdateSlowDownload|TestUpdateDownloadSaysStepAndSpeed': ok
- wsl-run (Ubuntu 24.04), -tags nogui: the same packages and ./internal/gui
-run TestUpdate: ok
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; go build; GOOS=linux go build -tags nogui;
GOOS=windows go build: clean
- Full suite: run after the push under the suite lock.
Broken by hand: fetch back on `client` fails
TestDownloadSlowButMovingOutlastsTheClientTimeout ("broke off ...
Client.Timeout or context cancellation while reading body"); the GUI's
download back under the check's ctx fails
TestUpdateSlowDownloadOutlastsTheCheckBound (state error, "context
deadline exceeded"); stall's reader not putting the timer off fails
TestSlowButMovingIsReadWhole (50 of 120 bytes); Bun's and Claude Code's
downloads unwatched fail their silent tests at the 20s bound ("context
deadline exceeded").
Not tried: a real update over a slow or throttled link, on any OS; a real
Bun or Claude Code download over one. The Mac's unpack and signature
check now run with no deadline (they had the 10 minutes before).
Fixes#5572
esir_tech on Discord: after clicking Update the progress sat on 17% and
looked stuck. Cause: nothing watched a download that stopped sending. A
connection GitHub's asset host keeps open but silent (seen from some
networks) held the percent still until the client's 10-minute timeout,
then failed. The waits between retries showed the same still percent, and
after the bytes the Mac's unpack and codesign check showed a stale 100%.
- internal/update: fetch cancels a body that sends nothing for 30s
(stallAfter) as a network error, so download's existing retry resumes it
with Range. A step callback (update.WithStep) names download, retry,
verify, unpack and signature.
- internal/gui: /api/update's downloading answer carries step, and speed
(bytes/s over the last ~5s; it falls to 0 when bytes stop).
- app.js: the pill says "Downloading… 50% · 1.5 MB/s", "Reconnecting…",
then "Verifying…", "Unpacking…", "Checking signature…"; its tooltip
carries the text where the tight header hides it. Settings' Version row
says the same after its MB count. i18n in zh, zh-TW, ja, de. Comments
cut to stay under the core script budget (not raised).
Run on mote (mote-run):
- go test ./internal/update ./internal/gui -run 'TestDownload|TestUpdate|TestStage|Budget': ok
- new: TestDownloadStallIsTriedAgain, TestDownloadStallEveryTimeSaysSo,
TestUpdateDownloadSaysStepAndSpeed, TestUpdateSpeedFallsWhenStalled
- GUI, chromium and webkit: update-download-steps (new: en, zh, zh-TW, ja,
de at 900 and 420px), update-download-percent, update-download,
update-row-steady, update-stuck, update-network, update-mirror: 178 pass
- i18n-en-no-cjk, header-relang: pass. i18n-keys "a plugin's words are
its own" is red on origin/main 0d70f335e too (plugins/library,
routing, usage i18n.js vs Go strings), untouched here.
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...: clean
Broken by hand: with the idle timer a no-op, TestDownloadStallIsTriedAgain
and TestDownloadStallEveryTimeSaysSo fail at their 20s bound (context
deadline exceeded); with speed left out of the answer
TestUpdateDownloadSaysStepAndSpeed fails ("never said how fast"); on the
old app.js/i18n.js update-download-steps fails in every case.
Not tried: a real update on a stalling network, a real Mac unpack and
codesign step (tests cover download/verify only), Windows/Linux runs.
The 10-minute total cap (client Timeout, GUI run ctx, CLI update) is
unchanged, so a moving download slower than ~140KB/s for the 83MB
Windows exe still fails at 10 minutes.
Reported-by: esir_tech