Repository navigation
dispatch tests: scope the fetch stub in server.test.ts so the suite is order-independent (#10609) - #10610
Merged
Conversation
…into later files (#10609)
Codex Review Summary: ❌ FailedThis 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Caution Review failedThe pull request is closed.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10609.
Root cause
pm-stack/dispatch/test/server.test.tsinstalled its throw-on-network fetch stub at module scope (lines 16-25) and never restored the capturedglobalThis.fetch. Bun runs the dispatch test files in one process, so wheneverserver.test.tswas evaluated beforeopencode.test.ts, the latter's real requests tohttp://127.0.0.1:<port>/api/session*hit the stub's guard: 4OpenCodeClienttests failed withunexpected network fetch in test: http://127.0.0.1:<port>/api/session.CI evidence: run 43807605419 (push, head bcb467e) failed step "Test dispatch" with 203 pass / 4 fail, exactly the OpenCodeClient failures. A
workflow_dispatchof the same head (run 43808691940) was green, and run 43792350594 (head ec68de7) was green with an identicalpm-stack/dispatchtree (git log ec68de7f..bcb467ece6 -- pm-stack/dispatchis empty). Order-dependent test pollution, not a product bug.Change
test/server.test.ts: the stub is installed inbeforeAlland the capturedrealFetchis restored inafterAll; an explicit assertion in that hook requires the restored value to be the runtime's native fetch (native code), so dropping the restore fails loudly.test/zz_fetch_hygiene.test.ts(new): guard test assertingglobalThis.fetchis the runtime's native fetch, so a leaked stub from any test file fails the suite. Thezz_name keeps it after the stubbing files in Bun's default filename order.Sibling files already restored correctly and were used as the model (
attach_verify.test.ts,auth.test.ts,github.test.ts,queue.test.ts); an audit ofpm-stack/dispatch/test/found no other unrestored global override.Verification
The 2 remaining failures in both full runs are the pre-existing host-network artifact on this laptop (
GitHubClient response-shape validation (#7101) > lookup {} ...and> lookup null body ...timing out at 5000ms); they appear identically on the unmodified tree and are unrelated to this change.bun run typecheckis clean.Not merging and not closing the issue — watcher merges after review.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.