Repository navigation
Description
Failure
Main-branch run 43807605419 (push, head bcb467ece6, workflow pm-stack tests) failed job aggregator + projector + dispatch + python suites + quota exporters at step Test dispatch — 203 pass / 4 fail:
(fail) OpenCodeClient auth file boundary (#7085) > control: a valid auth file resolves and sends the password verbatim
(fail) OpenCodeClient response body boundary (#7085) > a non-JSON 200 body is an OpenCodeError, not a raw SyntaxError
(fail) OpenCodeClient.getSession (#5555) > returns the session object on 200 (envelope unwrapped)
(fail) OpenCodeClient.getSession (#5555) > returns null on 404 — the session does not exist
error: opencode GET /api/session/ses_ok unreachable: unexpected network fetch in test: http://127.0.0.1:45791/api/session/ses_ok
It is a flake, and the defect is test isolation
A manual workflow_dispatch of the same workflow on the same head bcb467ece6 is green: run 43808691940 (dispatched 2026-11-16T05:12Z, success). The dispatch suite also passed on ec68de7f (run 43792350594) with an identical pm-stack/dispatch tree — no dispatch source changed between them.
Root cause: pm-stack/dispatch/test/server.test.ts installs a global fetch override at module scope and never restores it:
// pm-stack/dispatch/test/server.test.ts:16-25
const realFetch = globalThis.fetch;
globalThis.fetch = (async (input: unknown) => {
if (String(input) === JWKS_URL) { ... }
throw new Error(`unexpected network fetch in test: ${String(input)}`);
}) as typeof fetch;realFetch is captured but never restored. Bun executes the dispatch suite's 12 test files in one process, so once server.test.ts has been loaded, every later file that performs a real local-HTTP request (opencode.test.ts drives 127.0.0.1:<port>/api/session*) throws that guard. Whether the suite is red depends purely on file execution order — which is why the same tree goes green and red.
Sibling files already do this correctly (attach_verify.test.ts:148/171/181, auth.test.ts:246/259, github.test.ts:67, queue.test.ts:124 restore realFetch in their cleanup hooks). server.test.ts is the only module-scope stubbing file that never restores.
Fix
- Restore
globalThis.fetch = realFetchinserver.test.ts(anafterAll, plus per-testbeforeEach/afterEachscoping for the stub) so no state escapes the file. - Audit the suite for any other module-scope global mutation that is not restored.
- Add a guard test that fails when a global fetch override survives a test file (e.g. a small test that asserts
globalThis.fetchidentity before/after walking the suite), so a future leak cannot silently return.
Related
- Superseded tracker: developing-today/code / pm-stack tests: main run 43392266890 fails (aggregator + projector + dispatch + python suites + quota exporters) #9529 (same workflow, older
claimant install bun suite/ systemd-gatherer failure; that step is green now). - Earlier rounds on this workflow: developing-today/code / pm-stack tests: main run 43696785135 fails (aggregator + projector + dispatch + python suites + quota exporters) #10469, main CI failure: pm-stack tests — five aggregator tests fail #8737, ci(pm-stack): pm-stack tests red on main since 2026-11-04 — deploy-install-smoke fails 4 checks (aggregator unit cp resolves through the fixture symlink; ready-for-agent fixture missing apply-config.sh) #7680, main CI failure: pm-stack tests (run 42087275562) #6452 (all closed).
Activity
developing-today commentedon Nov 16, 2026
CODE-3850
dispatch tests: restore the fetch stub so server.test.ts cannot leak …
dezren39 commentedon Nov 16, 2026
Agent note — fix opened: #10610 (
queue/17411-main-ci-10609, commit 59ce15a; not merged, not closing this issue)Root cause confirmed as reported:
pm-stack/dispatch/test/server.test.tsreplacedglobalThis.fetchat module scope and never restored it, so whenever it was evaluated beforeopencode.test.tsthe OpenCodeClient's realhttp://127.0.0.1:<port>/api/session*calls threwunexpected network fetch in test: .... Reproduced deterministically on Bun 1.4.4 with--randomize(4 failures on seeds 3, 5, 7, 8, 10 of 10), matching run 43807605419.Fix: stub installed in
beforeAll,realFetchrestored inafterAllwith an explicit native-fetch assertion; new guard testtest/zz_fetch_hygiene.test.tsfails if any global fetch stub survives. Audit ofpm-stack/dispatch/test/found no other unrestored global override.Verification (all after the change):
bun test --randomize --seed=$s test/server.test.ts test/opencode.test.ts: 29 pass / 0 fail each (25/4 before the fix).bun test test/server.test.ts test/opencode.test.tsand the reverse order: 29 pass / 0 fail both.bun testtwice: 206 pass / 2 fail, 208 tests / 13 files. The 2 failures are the pre-existing host-networkgithub.test.tspm-dispatch(github): GitHub API response bodies are shape-trusted — a token-less access-token reply is sent as Bearer undefined, a wrong-shape create reply is returned as a successful issue, and a null create body falls back to a duplicate gh create #7101 timeouts, identical on the unmodified tree and unrelated.bun run typecheck: clean.Leaving the PR unmerged for watcher review.
Merge pull request #10610 from developing-today/queue/17411-main-ci-1…