Repository navigation
test(combos): await the fallback lease release on both passthrough relays - #7360
Conversation
Codex Review SummaryThis 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. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 1
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4af460b64f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| expect(getActiveTurnCount()).toBe(1); | ||
| expect(releases).toBe(0); | ||
| } | ||
| try { finish(); } catch { /* the tee relay already cancelled the upstream body */ } |
There was a problem hiding this comment.
Verify tee cancellation before completing upstream
In the tee/cancel row, calling finish() before checking the release lets the test pass even if cancelling the response no longer releases the lease: the injected terminal will independently finish inspection and unregister the turn. Only the eager row is supposed to need that terminal, so the tee row should assert the release after response.body.cancel() without completing upstream.
Useful? React with 👍 / 👎.
| finish(); | ||
| expect(await response.text()).toContain("held fallback"); | ||
| } | ||
| await releasedSignal; |
There was a problem hiding this comment.
Reset the relay override from afterEach
When a relay regression prevents the release callback, this promise remains pending until Bun times out the test; Bun then runs afterEach without resuming this async function, so the lexical finally never clears setRelayPlatformForTests. Because the existing afterEach does not reset that module-global override, all subsequent passthrough tests in the worker can run under the forced platform and produce cascading or misleading failures. Clear the override in afterEach as well.
Useful? React with 👍 / 👎.
Summary
Fixes the Windows
devCI failure in run 39212576911 (Windows shard 9/9, job 117929528851).tests/server/server-combo-zero-output-failover.test.ts› "accepted fallback keeps its turn lease until stream cancel" expectedgetActiveTurnCount()to be 0 right afterawait response.body.cancel(), but got 1.Diagnosis: the test asserted too early. This is not a lease leak and not a regression from #7354 or #7355. Passthrough SSE uses two relays. Linux and macOS (
streamMode: auto) use the tee relay, which unregisters the turn as soon as the client cancels. Windows uses the eager bounded relay (src/server/relay-eager.ts) for no-rewrite traffic on a fixed runtime. By its documented #44 cancel semantics, that relay keeps reading upstream in a bounded discard drain after a client cancel, so a terminal that really arrives is still recorded. It callsonDone(turn unregister, lease release) only when it sees a terminal or the drain window (15 s) expires. The fallback upstream in this test never sends a terminal, so on Windows the turn stays admitted aftercancel()by design. The release still happens exactly once, when the drain ends.Two scenarios do release immediately on every relay: a real client disconnect, because it aborts the request signal that the admission lease watches, and the
abortcase.Change (test only): these cases now run on both relay shapes on every OS, using the existing
setRelayPlatformForTestsseam:linuxselects tee, andwin32withstreamMode: "eager-relay"selects eager. Linux shards therefore cover the path that only Windows exercised before. The test now:No product code changes.
Verification
setRelayPlatformForTests("win32")), using an in-process stress loop under 8 CPU-burner processes:scripts/test.tsunder the same load: 40/40 runs green, 16 pass / 0 fail each.bun run typecheck: pass.Checklist