#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
A Claude subscription signs in and answers through the local `claude`, so
on a server or in the Docker image, which has none, it couldn't be used
(Jorben on Discord: could it be downloaded on first use, as Bun is).
- internal/claudecode: Anthropic's native build, as claude.ai/install.sh
takes it: downloads.claude.ai/claude-code-releases/latest names the
version, its manifest.json the platform's SHA-256 and size (linux
glibc/musl, darwin, win32). A build that doesn't match both is not kept.
It goes to <cache>/claude-code/<version>/claude, one version kept. Find
takes the machine's own claude first, then the download.
- magpie claude-code [install [--yes]|remove]: says the version, platform,
size, the URL it comes from, where it goes, that its checksum is checked
and that it is Anthropic's software under Anthropic's terms, then asks
[y/N]. magpie accounts add claude offers it when there is no Claude Code
(not on Windows, where one in WSL may be the one).
- the gateway's claudeBinary and the sign-in's claudeExecutable take
claudecode.Find; their "not installed" errors name the command.
- Docker docs (en, zh, ja): Claude sign-in needs `docker exec -it magpie
magpie claude-code install` first; kept in /config/cache.
The Dockerfile is unchanged: distroless cc-debian12 has glibc.
Run:
- go test -tags nogui ./... under a temp HOME with pinned caches: all ok
- gofmt -l: none; go vet (darwin), GOOS=linux and GOOS=windows go vet
-tags nogui ./...: clean; darwin, linux, windows builds
- TestClaudeSubscriptionRunsTheDownloadedClaudeCode fails on the old
proc.FindTool lookup ("Claude Code is not installed"); taking the
checksum compare out fails TestInstallRefusesABuildTheManifestDoesntName
- real: magpie claude-code install --yes downloaded Claude Code 2.1.296
darwin-arm64 (230 MB) into a sandbox HOME, checked; it ran --version
- real, in gcr.io/distroless/cc-debian12:nonroot with the image's /config
layout: install downloaded 2.1.296 linux-arm64 (245 MB) to
/config/cache/magpie/claude-code, it ran `2.1.296 (Claude Code)` there,
and magpie accounts add claude went on to print the claude.ai sign-in
link and ask for the pasted address
- the claudecode tests built for linux/arm64 pass in debian:12-slim