Repository navigation
test(server): keep the live-cancel pool fixture quota prime off the network - #8828
Conversation
… network The credential-resolution cancel case seeds an expired pool credential and spies on getValidCodexToken, but the startup and pre-route quota primes use a resolver captured at module load, so they POSTed the fixture refresh token to the real token endpoint. On a stalled network that refresh is bounded only by its 30 s ceiling and outlived the file's 15 s final cleanup (dev batch run 43854382432, macos 3/4). Route the prime through setCodexPoolQuotaTokenResolverForTests so it refuses before any dial, and settle background work before restoring the seam.
|
✅ Deterministic PR hygiene checks passed. |
Codex Review Summary: ✅ CompletedThis 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. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Maintainer integration of #8828 at c60342c (owner accepted this as the fix, 2026-11-16). This repairs the macos 3/4 failure in dev batch run 43854382432 (da021e3):
Follow-up (owner decision): no preload network block in this round. A read-only investigation will list every test that reaches a real provider host, and an issue will follow. |
Summary
tests/server/server-live-cancel.test.tsfailed its file-level final cleanup on dev batch run 43854382432 (job "macos 3/4", head da021e3) withbackground work never settled before final cleanup: codex-pool-quota-prime-startup, codex-pool-quota-prime:startup, codex-pool-quota-prime-import:pre-route. The defect is in the test, which made a real network call. The product is working as designed.The case "a client that cancels during credential resolution releases admission before any dial" seeds a pool account with an expired access token and a fixture refresh token. It spies on
accountStore.getValidCodexTokento hold the live request's credential resolution. The startup prime (src/server/index.ts) and the lazy pre-route prime (src/codex/auth-context.ts) share one single-flight pass inprimeCodexPoolQuotas, which resolves tokens throughgetValidPoolTokenForPrime. That variable captures the originalgetValidCodexTokenwhen the module loads, so the spy never reached it, and the prime POSTed the fixture refresh token to the real ChatGPT token endpoint. On a fast network the endpoint returns 401 almost at once, which explains the 15 earlier green batches. On a stalled runner network the only bound is the refresh flight's 30 sCODEX_REFRESH_FLIGHT_CEILING_MS, so all three tracked labels stay pending past the 15 s cleanup contract.server.stop()doesn't own this work, and this PR deliberately leaves that unchanged. The prime is process-scoped and bounded (30 s refresh ceiling, 8 s WHAM timeout). The refresh flight is intentionally not cancellable by any single owner, because aborting a refresh after upstream rotates the refresh token would lose the rotated grant (see the comment above the flight insrc/codex/account-store.ts).The fix routes the prime through the existing
setCodexPoolQuotaTokenResolverForTestsseam with a resolver that refuses before any dial. The test then settles background work in its ownfinallybefore restoring the seam and asserts{ settled: true, pending: [] }. The 15 s preload cleanup contract and its check are unchanged.Verification
I reproduced the failure deterministically by stalling the network. A local TCP listener on 127.0.0.1:47999 accepts connections and never responds, and the runs set
HTTPS_PROXY/HTTP_PROXYto it. Every run used/usr/bin/lockf -k /tmp/ocx-test.lock bun test --timeout 20000 tests/server/server-live-cancel.test.ts.background work outlived its case: codex-pool-quota-prime-startup, codex-pool-quota-prime:startup, codex-pool-quota-prime-import:pre-route, then(fail) (unnamed) [15003.28ms]with the samenever settled before final cleanuperror as CI. Without the stall, the original file logs[codex] pool refresh …: transient status=401, which shows the prime reaching the real token endpoint.bun run typecheck: no type errors.bun test tests/test-layout.test.ts,tests/test-layout-tooling.test.ts,tests/ci-workflows/file-size-ratchet.test.ts: all pass.NOT RUN:
bun run test(full suite; the host is under heavy load, and the task limited this work to focused single-file runs),bun run privacy:scan, the cross-platformlane=alldispatch (a batch check on dev, not per-PR), and macOS/Windows CI for this head.Checklist
Summary by CodeRabbit