Skip to content

fix(web): move route-proxy smoke imports out of beforeAll hook (AP-320)#516

Open
isuttell wants to merge 1 commit into
mainfrom
cursor/fix-route-proxy-smoke-hook-timeout-8f54
Open

fix(web): move route-proxy smoke imports out of beforeAll hook (AP-320)#516
isuttell wants to merge 1 commit into
mainfrom
cursor/fix-route-proxy-smoke-hook-timeout-8f54

Conversation

@isuttell

@isuttell isuttell commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes flaky Hook timed out in 10000ms failures in apps/web/test/route-proxy-smoke.test.ts during CI test:coverage.

PR #502 correctly added getGlobalStartContext mocks and moved route module loading into beforeAll to avoid parallel vitest races. The remaining flake is that dynamic imports inside beforeAll are subject to vitest's default 10s hookTimeout, and on cold 2-vCPU CI runners with v8 coverage instrumentation the three proxy route imports can exceed that budget.

Root cause

  • beforeAll runs three import() calls for TanStack Start API route modules.
  • Under --coverage, Vite must transform and instrument the route module graph on first load.
  • With parallel vitest workers on CPU-starved CI, that cold path can take >10s inside the hook.
  • Vitest does not apply hookTimeout to static module imports during file load.

Fix

Replace beforeAll dynamic imports with static imports placed after hoisted vi.mock calls. 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)
  • Full apps/web test:coverage with --maxWorkers=2 --pool=forks — 3 consecutive green runs

Closes AP-320.

Linear Issue: AP-320

Open in Web Open in Cursor 

Summary by CodeRabbit

  • Tests
    • Updated route proxy smoke tests to use static imports for TanStack route modules instead of dynamic imports.
    • Refactored test structure to directly access route modules rather than through shared state storage.
    • Added clarifying comments regarding route handler module loading interactions.

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>
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c10c79c8-b7a6-4f08-9157-7271fa986a5d

📥 Commits

Reviewing files that changed from the base of the PR and between 76bb772 and 5688794.

📒 Files selected for processing (1)
  • apps/web/test/route-proxy-smoke.test.ts

📝 Walkthrough

Walkthrough

This PR refactors the smoke test suite to use static imports for TanStack route modules instead of dynamically loading them in a beforeAll hook. The change removes hoisted test state and updates all six test cases to reference imported routes directly.

Changes

Test Import Refactoring

Layer / File(s) Summary
Test setup: convert to static imports
apps/web/test/route-proxy-smoke.test.ts
Vitest import drops beforeAll; hoisted state.routes object removed. Static imports of artifactLiveRoute, accessLinkLiveRoute, and accessLinkResolveRoute added to describe block with comments explaining route handler module loading under vitest instrumentation and mocked auth context.
Test cases: replace dynamic route references
apps/web/test/route-proxy-smoke.test.ts
All six test references updated from state.routes.artifactLive! / state.routes.accessLinkLive! / state.routes.accessLinkResolve! to direct access of statically imported route modules.

Possibly Related PRs

  • zaks-io/agent-paste#465: Directly affects the same smoke tests by changing how the route handlers are obtained and executed.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Routes now stand still, no hooks in the way,
Static they shimmer through test and through day,
No beforeAll dance, no state to untie,
Just imports so clean as we test and we fly! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: moving route-proxy smoke test imports from a beforeAll hook to static imports to fix timeout issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/fix-route-proxy-smoke-hook-timeout-8f54

Comment @coderabbitai help to get the list of available commands and usage tips.

@cursor cursor Bot marked this pull request as ready for review June 14, 2026 13:04

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First-pass review (AP-320)

Risk: simple
Decision: approve

Ticket triage

  • Intended change: Stop flaky Hook timed out in 10000ms in route-proxy-smoke.test.ts under CI test:coverage by fixing the root cause (dynamic route imports running inside a timed beforeAll hook).
  • Scope match: Yes — single test file only; preserves the #502 getGlobalStartContext mock 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
Open in Web View Automation 

Sent by Cursor Automation: First Pass PR Reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants