fix(web): move route-proxy smoke imports out of beforeAll hook (AP-320)#516
fix(web): move route-proxy smoke imports out of beforeAll hook (AP-320)#516isuttell wants to merge 1 commit into
Conversation
PR #502 preloaded proxy route modules in beforeAll to avoid parallel vitest races with TanStack Start context. Under test:coverage on 2-vCPU CI runners, that hook's dynamic imports trigger cold Vite transform plus v8 instrumentation of the route module graph and can exceed vitest's default 10s hookTimeout. Use static imports after hoisted vi.mock calls instead. Module loading happens at file init (not subject to hookTimeout) while mocks still apply before the route graph resolves. Keeps the getGlobalStartContext mock from #502. Co-authored-by: Isaac Suttell <isaac@isaacsuttell.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR refactors the smoke test suite to use static imports for TanStack route modules instead of dynamically loading them in a ChangesTest Import Refactoring
Possibly Related PRs
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
First-pass review (AP-320)
Risk: simple
Decision: approve
Ticket triage
- Intended change: Stop flaky
Hook timed out in 10000msinroute-proxy-smoke.test.tsunder CItest:coverageby fixing the root cause (dynamic route imports running inside a timedbeforeAllhook). - Scope match: Yes — single test file only; preserves the
#502getGlobalStartContextmock stabilization.
Review summary
The fix is sound. beforeAll dynamic import() of three TanStack Start route modules was subject to vitest's default 10s hookTimeout; on cold 2-vCPU CI with v8 coverage instrumentation that cold transform path can exceed the budget. Moving to static imports after hoisted vi.mock calls matches established patterns in web-mutations.test.ts and web-loaders.test.ts, keeps mocks in place before the route graph resolves, and shifts module load to file init (not hook-bounded). No production code, auth, or infra touched.
Merge checklist
- Ticket linked: AP-320
- Scope matches: yes
- Checks green: Validate, Postgres smoke, CodeQL, secret scan all passed on PR push
- Tests/docs appropriate: yes (inline root-cause comment + PR description)
- No blocking findings
- No high-risk areas
- Merge-safe: yes
Sent by Cursor Automation: First Pass PR Reviewer


Summary
Fixes flaky
Hook timed out in 10000msfailures inapps/web/test/route-proxy-smoke.test.tsduring CItest:coverage.PR #502 correctly added
getGlobalStartContextmocks and moved route module loading intobeforeAllto avoid parallel vitest races. The remaining flake is that dynamic imports insidebeforeAllare subject to vitest's default 10shookTimeout, and on cold 2-vCPU CI runners with v8 coverage instrumentation the three proxy route imports can exceed that budget.Root cause
beforeAllruns threeimport()calls for TanStack Start API route modules.--coverage, Vite must transform and instrument the route module graph on first load.hookTimeoutto static module imports during file load.Fix
Replace
beforeAlldynamic imports with static imports placed after hoistedvi.mockcalls. Mocks still apply before the route graph resolves (same stabilization as #502), but module loading happens at file init instead of inside a timed hook.Verification
npx vitest run --coverage test/route-proxy-smoke.test.ts— passes (~1.8s, import ~1.07s)apps/webtest:coveragewith--maxWorkers=2 --pool=forks— 3 consecutive green runsCloses AP-320.
Linear Issue: AP-320
Summary by CodeRabbit