Files
magpie/internal/source
yetoneandump45nose ff72eeda52 source: the last-source budget test reads which context ended instead of racing sleeps (#2608)
TestDoLastSourceUsesRemainingBudget slept 1100ms (official) and 700ms
(mirror) under a 2s parent, leaving ~300ms for scheduling. It now uses a
controlled RoundTripper: the official request waits on its candidate
context and must end with context.Canceled (its half of the budget), and
the mirror request must carry the parent's deadline and end with
DeadlineExceeded no earlier than it. A second test adds #2608's 350ms
pause before the mirror request. Patch by ump45nose; the review dropped
an unused parentDeadline field.

What ran (worktree at origin/main 81313b912, sandbox HOME, go1.26.8
darwin/arm64, load ~270-300):
- Flake reproduced: main's test with a 350ms pause before the mirror
  request: FAIL in 2.06s (official canceled, mirror deadline exceeded).
  The new tests pass with and without that pause.
- Broken by hand, both new tests red: candidateContext(..., true) for the
  last candidate ("mirror request ended with context canceled 495ms
  before the parent's deadline"), and a WithTimeout(remaining/2) on the
  last candidate ("mirror deadline = ..., want the parent's ...").
- gofmt -l . clean; go vet -tags nogui ./... for darwin, linux, windows.
- set -o pipefail; go test -count=1 -timeout 45m ./...: 65 packages ok,
  internal/source ok, internal/gateway ok (1430s). internal/gui red on
  TestMainWindowCorners (both SDKs "measuring the windows: signal:
  killed" at its 40s deadline, #1936) and, on a rerun of internal/gui
  alone, TestSetAnswersWhileDevinAndProvidersHang (#1375). Both are
  filed load reds in a package this commit doesn't touch.

Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-10-17 03:22:55 +08:00
..
plugins: a 「国内镜像」 switch on the Plugins page downloads the list, plugins and Bun from mirrors in China first (Discord, akic404: GitHub/npm are slow from the mainland; asked for ghproxy) — Plugins › Mirrors in China, off by default, kept in settings (chinaMirror). On, source asks a copy of the very file before its official address: npm's registry (packages, versions, search) at registry.npmmirror.com, Bun's release zips at registry.npmmirror.com/-/binary/bun, and the community registry.json at cdn.jsdelivr.net/gh/magpie-community/plugins@<branch>; bun add gets BUN_CONFIG_REGISTRY=npmmirror unless the environment names a registry. No proxy: gh-proxy (MAGPIE_MIRRORS' GitHub fallback) handles nothing the switch sends, since a proxy could hand back other code. A mirror asked first that can't answer (404/403/5xx, e.g. a version it hasn't synced) falls through to the official address; npm's weekly downloads stay api.npmjs.org's (npmmirror counts its own). Checked by hand: npmmirror's bun-v1.4.2 darwin-aarch64 zip has the SHA-256 pinned in bun.go, jsDelivr's registry.json is byte-identical to raw.githubusercontent's, and bun 1.4.2 add through npmmirror locks the same sha512 integrity npmjs gives. TestChinaFirst, TestChinaComesFirst, TestChinaMirrorAnswers, TestChinaMirrorsMissIsAskedOfficially, TestDoFaithful, TestBunInstallsFromChinaMirror and TestPluginsMirrorSwitch cover it. A live run with the switch on fetched the list from jsDelivr, npm info from npmmirror and Bun from npmmirror (checksum passed); a sandbox magpie web showed the switch in the Plugins head, saved it, kept it after a reload, and a click didn't move the page. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried from inside mainland China.
2026-10-03 15:14:45 +08:00