fix(tests): capture the real resolver before mocking adapter-resolve - #5482
FredAmartey wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe test mocks capture the original ChangesAdapter resolver mock isolation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to This test-only change captures the original resolver before module overrides, preventing recursive mocks without changing production behavior. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Three test files wrap `resolveAdapter` through `mock.module` and fall back to the real function by reading `actualResolver.resolveAdapter` at call time. Bun rewrites that namespace binding in place, so once a second file in the same process installs its own override, the fallback resolves to the newest wrapper and the two call each other until the stack overflows. CI never meets this because every lane passes `--isolate`, which gives each file its own module registry. A plain `bun test <files>` does not, and `tests/adapters/abort-race.test.ts` shares shard 1 batch 1 with `anthropic-quota-dispatch.test.ts`, so that invocation fails 11 of its cases with `RangeError: Maximum call stack size exceeded`. Capture the real function once, before the override, the way the other resolver wrappers already do.
4cc38f6 to
0aed302
Compare
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. |
리뷰 · 우선순위 71 / 80이 PR은 실제 서버 코드는 건드리지 않고, Bun 테스트 세 개만 고칩니다. 세 파일 모두 라인 - PR 본문의 “ready for review” 체크리스트가 아직 비어 있고 상태가 draft라, 머지 타이밍은 작성자가 준비 완료로 표시할 때까지 메인테이너 쪽에서 한 번 더 보면 좋겠습니다. 메인테이너의 판단이 필요한 지점
너의 추천
이 댓글은 grok-bot이 작성했습니다 |
…EADME inventory counts (#5672) * docs(devlog): triage the lane A tests-hygiene bundle * fix(tests): capture the real resolver before mocking adapter-resolve Carries #5482. Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> * fix(tests): dispose test translator budgets in every file that creates them Carries #5607. Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> * fix(tests): restore the sandbox home after every test file Carries #5570 (both PR commits, including the CodeRabbit ordering fix). Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> * fix(tests): put the real modules back after the image tests mock them Carries #5605. Folded review fix: each file restores only the module snapshots it actually captured, so a beforeAll that failed partway cannot install an empty module, and z-handler-activation restores its overrides in a finally block so a failed directory removal cannot leave them installed for later files in the process. Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> * fix(desktop): never restart the real desktop app from the test runner Carries #5630. restartCodexDesktopApp returns the skipped reason test_environment when the test preload armed OCX_TEST_HOME_GUARD and no execFile was injected, and the CLI reports that skip. Folded review fix: structure/runtime.md documents the guarded outcome next to the CLI restart scope it owns. Co-authored-by: terin <100397903+sh940701@users.noreply.github.com> * docs(readme): derive the memory inventory counts instead of restating them Carries #5340, rebuilt on dev after #5615 and #5638 so their README and locale prose stays intact. Folded review fixes: dev now registers 14 retained stores, and native_control_replay is pinned (evictOldest returns 0), so every page says 14 and names the one store the budget never evicts; the guard's header drops the numbers that had gone stale; readme/i18n-manifest.json carries the hash of the final README.md. Co-authored-by: codingbo <9621077+codingbooo@users.noreply.github.com> * docs(devlog): record the lane A delivery --------- Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> Co-authored-by: terin <100397903+sh940701@users.noreply.github.com> Co-authored-by: codingbo <9621077+codingbooo@users.noreply.github.com>
Summary
tests/adapters/abort-race.test.ts,tests/claude-integration/claude-code-thought-signature-scope.test.tsandtests/routing/routing-policy-surface-parity.test.tsoverrideresolveAdapterwithmock.moduleand fall back to the real function by readingactualResolver.resolveAdapterwhen the call is made. Bun rewrites that live binding in place, so as soon as another file in the same process installs its own override, the fallback resolves to the newest wrapper. The two wrappers then call each other until the stack overflows.abort-race.test.tssits in shard 1 batch 1 next toanthropic-quota-dispatch.test.ts, which also overrides the module. Run those two files in one process without--isolateand 11 of the quota-dispatch cases fail withRangeError: Maximum call stack size exceeded, on macOS and Linux alike. Each file passes alone, becauseabort-racesets its factory in every case and never reaches the fallback.bun run test, passes--isolate, so each file gets its own module registry. The plainbun test <files>a contributor types by hand does not, which is one of the ways the failure count in Batched test runner cannot run on macOS, and one-process runs give batch-size-dependent failure counts #5439 comes to depend on how the files are sliced.actualResolver.resolveAdapteronce, before the override, which is what the other seven resolver wrappers in the tree already do. No runtime code changes.Verification
Head
0aed30205on dev39143fddf, Bun 1.4.0 (thebundependency inpackage.json). The pair, the six-file run, typecheck, structure, privacy, layout andgit diff --checkwere rerun on this head after the rebase; the shard runs below were made on the previous basee4ceeb38d, and the change carries no conflicts across:bun test tests/adapters/abort-race.test.ts tests/adapters/anthropic/anthropic-quota-dispatch.test.tsgives 5 pass, 11 fail, allMaximum call stack size exceeded. Same result in anoven/bun:1.4.0Linux container. With--isolatethe same pair passes, which is why dev is green.anthropic-quota-dispatch,terminal-continuation-owner-rotationandanthropic-sidecar-account-failovergive 30 pass, 0 fail, all without--isolate.bash scripts/ci/run-bun-test-batches.sh 1/4on macOS: batches 1 to 6 pass; batch 7 stops onremote-workspace-command-runner.test.ts, which fails alone on this machine too (bubblewrap must be a private executable file) and is unrelated. Batches 8 to 32 rerun by hand with the same slicing: 20 batches clean; the failures in batches 11, 14, 21, 29 and 31 (codex-shim,winsw,service-tier-capability,vision-reasoning-contract) reproduce on untouched dev.bun run typecheck,bun run structure:check,bun run privacy:scan,bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts(18 pass) andgit diff --check: passed.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit