fix(solid-router): implement navigation transitions #5691
main fromrefs/pull/5691/head·merged by birkskyum(GitHub profile, opens in a new tab) closes #5636
Summary by CodeRabbit#
New Features
- Added a /transition route (examples for multiple frameworks) demonstrating in-place data transitions.
Bug Fixes
- Navigation now preserves previous view content during transitions and avoids unwanted loading flashes.
- Route matching and component rendering made more resilient during navigation.
Tests
- Added end-to-end tests ensuring transitions preserve prior data and update without "Loading...".
- Updated unit test expectations and skipped one flaky navigation test.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-router
View your CI Pipeline Execution ↗ for commit 30643138890027a0b58e7f757b034f62ee966051
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 58s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 3s View ↗
☁️ Nx Cloud last updated this comment at
2025-11-04 02:44:52UTCMore templates
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-solid-start-example-bare
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-example-basic-supabase
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5691@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5691@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5691@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5691@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5691@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5691@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5691@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5691@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5691@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5691@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5691@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5691@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5691@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5691@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5691@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5691@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5691@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5691@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5691@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5691@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5691@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5691@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5691@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5691@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5691@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5691@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5691@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5691@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5691@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5691@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5691@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5691@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5691@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5691@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5691commit:
3064313birkskyum(GitHub profile, opens in a new tab) changed the title
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 1ec38819b62343534b83ace70aa6f7318688079f and 73b4984c893f03ff8aa2604b3136e8fff9135994.
📒 Files selected for processing (5)
e2e/solid-router/basic-file-based/src/routeTree.gen.ts(11 hunks)e2e/solid-router/basic-file-based/src/routes/transition/index.tsx(1 hunks)e2e/solid-router/basic-file-based/tests/transition.spec.ts(1 hunks)packages/router-core/src/router.ts(2 hunks)packages/solid-router/src/Transitioner.tsx(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
e2e/solid-router/basic-file-based/tests/transition.spec.tspackages/router-core/src/router.tspackages/solid-router/src/Transitioner.tsxe2e/solid-router/basic-file-based/src/routeTree.gen.tse2e/solid-router/basic-file-based/src/routes/transition/index.tsx
e2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Store end-to-end tests under the e2e/ directory
Files:
e2e/solid-router/basic-file-based/tests/transition.spec.tse2e/solid-router/basic-file-based/src/routeTree.gen.tse2e/solid-router/basic-file-based/src/routes/transition/index.tsx
packages/router-core/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep framework-agnostic core router logic in packages/router-core/
Files:
packages/router-core/src/router.ts
packages/{react-router,solid-router}/**
📄 CodeRabbit inference engine (AGENTS.md)
Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Files:
packages/solid-router/src/Transitioner.tsx
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
e2e/solid-router/basic-file-based/src/routes/transition/index.tsx
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad PR: TanStack/router#5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
e2e/solid-router/basic-file-based/tests/transition.spec.tse2e/solid-router/basic-file-based/src/routeTree.gen.tse2e/solid-router/basic-file-based/src/routes/transition/index.tsx
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/Applied to files:
packages/router-core/src/router.ts
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Applied to files:
packages/solid-router/src/Transitioner.tsxe2e/solid-router/basic-file-based/src/routeTree.gen.tse2e/solid-router/basic-file-based/src/routes/transition/index.tsx
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel PR: TanStack/router#5330 File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61 Timestamp: 2025-10-01T18:31:35.420Z Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.Applied to files:
e2e/solid-router/basic-file-based/src/routeTree.gen.tse2e/solid-router/basic-file-based/src/routes/transition/index.tsx
📚 Learning: 2025-09-28T21:41:45.233Z
Learnt from: nlynzaad PR: TanStack/router#5284 File: e2e/react-start/basic/server.js:50-0 Timestamp: 2025-09-28T21:41:45.233Z Learning: In Express v5, catch-all routes must use named wildcards. Use `/*splat` to match everything except root path, or `/{*splat}` (with braces) to match including root path. The old `*` syntax is not allowed and will cause "Missing parameter name" errors. This breaking change requires explicit naming of wildcard parameters.Applied to files:
e2e/solid-router/basic-file-based/src/routeTree.gen.ts
📚 Learning: 2025-10-14T18:59:33.990Z
Learnt from: FatahChan PR: TanStack/router#5475 File: e2e/react-start/basic-prerendering/src/routes/redirect/$target/via-beforeLoad.tsx:8-0 Timestamp: 2025-10-14T18:59:33.990Z Learning: In TanStack Router e2e test files, when a route parameter is validated at the route level (e.g., using zod in validateSearch or param validation), switch statements on that parameter do not require a default case, as the validation ensures only expected values will reach the switch.Applied to files:
e2e/solid-router/basic-file-based/src/routes/transition/index.tsx
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to **/src/routes/** : Place file-based routes under src/routes/ directoriesApplied to files:
e2e/solid-router/basic-file-based/src/routes/transition/index.tsx
🧬 Code graph analysis (2)
packages/router-core/src/router.ts (1)
packages/router-core/src/Matches.ts (1)
AnyRouteMatch(240-240)
packages/solid-router/src/Transitioner.tsx (1)
packages/solid-router/src/link.tsx (1)
isTransitioning(581-583)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
🔇 Additional comments (4)
packages/router-core/src/router.ts (2)
941-946: LGTM: Clean framework-agnostic extension point.The
wrapBatchhook provides a well-designed extension point for framework-specific transition handling. The default no-op implementation ensures backward compatibility while allowing frameworks like Solid to opt into custom batching behavior.Based on coding guidelines
2105-2141: LGTM: Correct integration of wrapBatch for transition-aware batching.The refactoring correctly hoists the match array declarations outside
wrapBatchso they can be accessed by the lifecycle hooks (lines 2143-2154). The batch operation and cache cleanup are properly wrapped, enabling framework-specific transition handling while preserving the existing state update logic.packages/solid-router/src/Transitioner.tsx (2)
64-71: LGTM: Proper async lifecycle management.The try/finally block correctly ensures that
isTransitioningis always reset, even if the navigation fails. The separation of concerns between tracking the transition state here and wrapping batch updates inwrapBatchis well-designed and clearly documented.Based on coding guidelines
38-60: No actionable concerns found.The jsdom detection in
wrapBatch(line 48) is part of a multi-layered guard strategy that works correctly. The approach has three safety checks:isRealBrowser && !router.isServer && isTransitioning(). The test suite validates this behavior in both jsdom (standard tests) and server environments (server mode tests), confirming the detection works as intended. The fallback behavior—directly executing the callback—is safe in all scenarios wherestartTransitionis skipped.@@ -0,0 +16,21 @@16+ // Poll the body text during the transition17+ const pollInterval = setInterval(async () => {18+ const text = await page.locator('body').textContent().catch(() => '')19+ if (text) bodyTexts.push(text)20+ }, 50)21+22+ // Click the increase button to trigger navigation with new search params23+ await page.getByTestId('increase-button').click()24+25+ // Wait a bit to capture text during the transition26+ await page.waitForTimeout(200)27+28+ clearInterval(pollInterval)29+30+ // Eventually, new values should appear31+ await expect(page.getByTestId('n-value')).toContainText('n: 2', {32+ timeout: 2000,33+ })34+ await expect(page.getByTestId('double-value')).toContainText('double: 4', {35+ timeout: 2000,36+ })⚠️ Potential issue | 🟠 Major
Guard against leaking the polling interval on failures.
If any assertion between starting the interval and calling
clearIntervalthrows (for example, the click hangs), the timer keeps running against a disposed page. That leaves an active handle in the worker and can make later tests flaky or hang. Please ensure the interval is always cleared viatry/finally.Apply this diff:
- const pollInterval = setInterval(async () => { - const text = await page.locator('body').textContent().catch(() => '') - if (text) bodyTexts.push(text) - }, 50) - - // Click the increase button to trigger navigation with new search params - await page.getByTestId('increase-button').click() - - // Wait a bit to capture text during the transition - await page.waitForTimeout(200) - - clearInterval(pollInterval) + const pollInterval = setInterval(async () => { + const text = await page.locator('body').textContent().catch(() => '') + if (text) bodyTexts.push(text) + }, 50) + + try { + // Click the increase button to trigger navigation with new search params + await page.getByTestId('increase-button').click() + + // Wait a bit to capture text during the transition + await page.waitForTimeout(200) + } finally { + clearInterval(pollInterval) + }📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const pollInterval = setInterval(async () => { const text = await page.locator('body').textContent().catch(() => '') if (text) bodyTexts.push(text) }, 50) try { // Click the increase button to trigger navigation with new search params await page.getByTestId('increase-button').click() // Wait a bit to capture text during the transition await page.waitForTimeout(200) } finally { clearInterval(pollInterval) } // Eventually, new values should appear await expect(page.getByTestId('n-value')).toContainText('n: 2', { timeout: 2000, }) await expect(page.getByTestId('double-value')).toContainText('double: 4', { timeout: 2000, })🤖 Prompt for AI Agents
In e2e/solid-router/basic-file-based/tests/transition.spec.ts around lines 17 to 36, the polling interval started before the click is not guaranteed to be cleared if an assertion or click throws; wrap the actions that depend on the interval (the click, waitForTimeout, and the subsequent assertions) inside a try block and call clearInterval(pollInterval) in a finally block so the timer is always cleared even on failures; ensure the finally runs before making further cleanup or test teardown.Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/solid-router/src/Transitioner.tsx (1)
38-52: Consider caching theisRealBrowsercheck for performance.The
isRealBrowsercomputation runs on everywrapBatchinvocation, which could be frequent during navigation. Since the browser environment doesn't change during the component lifecycle, consider computing this once during mount and storing it in a variable.Apply this diff to optimize:
const [isTransitioning, setIsTransitioning] = Solid.createSignal(false) + + const isRealBrowser = + typeof window !== 'undefined' && + typeof window.navigator !== 'undefined' && + typeof window.navigator.userAgent === 'string' && + !window.navigator.userAgent.includes('jsdom') router.wrapBatch = (fn: () => void) => { - const isRealBrowser = - typeof window !== 'undefined' && - typeof window.navigator !== 'undefined' && - typeof window.navigator.userAgent === 'string' && - !window.navigator.userAgent.includes('jsdom') - if (isRealBrowser && isTransitioning()) { Solid.startTransition(() => { fn() }) } else { fn() } }📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 05672a27c338d7b877d3acd09e89ee4c01112616 and 16ab2432cd971e9a213a149aaa824731ef540462.
📒 Files selected for processing (2)
packages/router-core/src/router.ts(2 hunks)packages/solid-router/src/Transitioner.tsx(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/solid-router/src/Transitioner.tsxpackages/router-core/src/router.ts
packages/{react-router,solid-router}/**
📄 CodeRabbit inference engine (AGENTS.md)
Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Files:
packages/solid-router/src/Transitioner.tsx
packages/router-core/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep framework-agnostic core router logic in packages/router-core/
Files:
packages/router-core/src/router.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Learnt from: nlynzaad PR: TanStack/router#5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Applied to files:
packages/solid-router/src/Transitioner.tsx
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/Applied to files:
packages/router-core/src/router.ts
🧬 Code graph analysis (2)
packages/solid-router/src/Transitioner.tsx (1)
packages/solid-router/src/link.tsx (1)
isTransitioning(581-583)
packages/router-core/src/router.ts (1)
packages/router-core/src/Matches.ts (1)
AnyRouteMatch(240-240)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Preview
- GitHub Check: Test
🔇 Additional comments (4)
packages/solid-router/src/Transitioner.tsx (2)
23-23: Minor formatting change.The extra blank line improves readability.
54-61: Excellent error handling improvement.The try/finally block ensures
isTransitioningis always reset, even if the transition function throws. This prevents the router from getting stuck in a transitioning state.packages/router-core/src/router.ts (2)
949-954: Well-designed framework extension point.The
wrapBatchmethod provides a clean hook for framework-specific transition handling while keeping the core router framework-agnostic. The default no-op implementation and clear documentation make this easy for framework adapters to override.
2105-2141: Refactoring correctly enables framework-specific transition wrapping.The refactored logic wraps the batch operation in
wrapBatch, allowing framework adapters like Solid to inject transition handling around state updates. The match computation moved inside the wrapped context is necessary for Solid's reactivity tracking to work correctly.The closure correctly captures
exitingMatches,enteringMatches, andstayingMatchesfor use in lifecycle hooks after the batch completes.github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-start
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 367f8bf86c0e802920683af61961da3c9d00a015 and 6fc2d8b262fd4f8bd4f052c486c46701928e5003.
📒 Files selected for processing (2)
packages/solid-router/src/Transitioner.tsx(2 hunks)packages/solid-start/src/useServerFn.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/solid-router/src/Transitioner.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/solid-start/src/useServerFn.ts
packages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Name and place Start framework packages under packages/-start/ or packages/start-/
Files:
packages/solid-start/src/useServerFn.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Learnt from: nlynzaad PR: TanStack/router#5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel PR: TanStack/router#5330 File: packages/router-core/src/router.ts:2231-2245 Timestamp: 2025-10-01T18:30:26.591Z Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.Applied to files:
packages/solid-start/src/useServerFn.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
🔇 Additional comments (1)
packages/solid-start/src/useServerFn.ts (1)
21-26: Race condition concern is technically valid but requires architectural evaluation.Concurrent server function calls do occur in practice (confirmed via
Promise.allpatterns in e2e tests), and the shared_isServerFnRedirectflag can indeed be cleared prematurely by the first redirect'sfinally()block while other navigations are in progress.However, this pattern appears intentional for Solid's architecture—the comment states the flag exists to "skip Solid transitions" during server function redirects. React-start omits this flag entirely, suggesting different architectural needs between frameworks.
The suggested fix (passing flag as navigation options) requires verifying whether the router's navigation API supports this parameter. Alternatively, consider whether the race condition's actual impact (skipping the "skip transitions" behavior for concurrent redirects) warrants mitigation given the Solid-specific requirements.
@@ -17,4 +17,5 @@1717 } catch (err) {1818 if (isRedirect(err)) {1919 err.options._fromLocation = router.state.location20- return router.navigate(router.resolveRedirect(err).options)20+ // Mark this as a server function redirect to skip Solid transitions21+ ;(router as any)._isServerFnRedirect = true⚠️ Potential issue | 🟠 Major
Type safety violation: avoid
anytype assertion in strict TypeScript.Using
(router as any)bypasses TypeScript's type checking and defeats the purpose of strict mode. This creates a maintenance risk as the router's API evolves.Consider one of these approaches:
Option 1: Add the flag to navigation options (preferred)
- // Mark this as a server function redirect to skip Solid transitions - ;(router as any)._isServerFnRedirect = true - const result = router.navigate(router.resolveRedirect(err).options) - // Clear the flag after navigation starts - result.finally(() => { - ;(router as any)._isServerFnRedirect = false - }) - return result + // Mark this as a server function redirect to skip Solid transitions + const result = router.navigate({ + ...router.resolveRedirect(err).options, + _isServerFnRedirect: true, + }) + return resultOption 2: Properly type the router extension
interface RouterWithServerFnFlag { _isServerFnRedirect?: boolean } // Then use: (router as RouterWithServerFnFlag)._isServerFnRedirect = trueOption 1 is cleaner as it avoids shared mutable state and eliminates the need for the finally block.
🤖 Prompt for AI Agents
In packages/solid-start/src/useServerFn.ts around line 21 you assign a flag using an any cast which breaks strict TypeScript; instead add a typed navigation option (e.g., extend the existing navigate/redirect options type to include an optional _isServerFnRedirect boolean) and pass that flag through the navigation call so you can remove the (router as any) cast and the shared mutable state/finally block; if you must keep the router mutation, declare a small interface for the router extension with _isServerFnRedirect?: boolean and cast to that interface rather than any.github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-router
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/solid-router/tests/router.test.tsx (1)
1681-1685: Consider aligning this test with the similar loader test or clarifying the intent.The root route now includes a
notFoundComponent, but the similar test above (lines 1640-1676, "loader throws a notFound()") creates the root route without this option. Additionally, the specific route at lines 1700-1702 already defines its ownnotFoundComponentwith identical content.If this change is intentional to test fallback behavior or component precedence, consider adding a comment explaining the difference. Otherwise, for consistency and clarity, align both tests to use the same pattern.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 39dc575a389d17c5f0cdcffdad34b1c7a9a69489 and 2f53719646a23bc03d8bd3845c38a40f31ac3028.
📒 Files selected for processing (1)
packages/solid-router/tests/router.test.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/solid-router/tests/router.test.tsx
packages/{react-router,solid-router}/**
📄 CodeRabbit inference engine (AGENTS.md)
Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Files:
packages/solid-router/tests/router.test.tsx
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Learnt from: nlynzaad PR: TanStack/router#5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad PR: TanStack/router#5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
packages/solid-router/tests/router.test.tsx
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR PR: TanStack/router#0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Applied to files:
packages/solid-router/tests/router.test.tsx
📚 Learning: 2025-10-14T18:59:33.990Z
Learnt from: FatahChan PR: TanStack/router#5475 File: e2e/react-start/basic-prerendering/src/routes/redirect/$target/via-beforeLoad.tsx:8-0 Timestamp: 2025-10-14T18:59:33.990Z Learning: In TanStack Router e2e test files, when a route parameter is validated at the route level (e.g., using zod in validateSearch or param validation), switch statements on that parameter do not require a default case, as the validation ensures only expected values will reach the switch.Applied to files:
packages/solid-router/tests/router.test.tsx
📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel PR: TanStack/router#5330 File: packages/router-core/src/router.ts:2231-2245 Timestamp: 2025-10-01T18:30:26.591Z Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.Applied to files:
packages/solid-router/tests/router.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
Actionable comments posted: 3
♻️ Duplicate comments (1)
e2e/solid-router/basic-file-based/tests/transition.spec.ts (1)
17-32: Always clear the polling interval.If the click or wait throws, the interval keeps running against a torn-down page, leading to flaky tests. Wrap the interaction in
try/finallyand clear the interval in thefinallyblock so it always tears down.- const pollInterval = setInterval(async () => { - const text = await page - .locator('body') - .textContent() - .catch(() => '') - if (text) bodyTexts.push(text) - }, 50) - - // Click the increase button to trigger navigation with new search params - await page.getByTestId('increase-button').click() - - // Wait a bit to capture text during the transition - await page.waitForTimeout(200) - - clearInterval(pollInterval) + const pollInterval = setInterval(async () => { + const text = await page + .locator('body') + .textContent() + .catch(() => '') + if (text) bodyTexts.push(text) + }, 50) + + try { + // Click the increase button to trigger navigation with new search params + await page.getByTestId('increase-button').click() + + // Wait a bit to capture text during the transition + await page.waitForTimeout(200) + } finally { + clearInterval(pollInterval) + }🧹 Nitpick comments (2)
packages/solid-router/tests/link.test.tsx (2)
785-793: Good synchronization for navigation side-effects.The
waitForwrappers properly ensure that both the URL search parameters and DOM content have updated before assertions. This aligns with the PR's objective of handling navigation transitions correctly.Consider consolidating the pathname assertion at line 788 into the first
waitForblock for consistency:await waitFor(() => { expect(window.location.search).toBe('?page=2&filter=inactive') + expect(window.location.pathname).toBe('/posts') }) - expect(window.location.pathname).toBe('/posts')
900-910: Navigation synchronization is correctly implemented.The
waitForwrappers ensure navigation transitions complete before assertions, consistent with the fix for manual Suspense boundaries during navigation.For consistency, consider consolidating the pathname assertion at line 903 into the first
waitForblock:await waitFor(() => { expect(window.location.search).toBe('?page=2&filter=inactive') + expect(window.location.pathname).toBe('/Dashboard/posts') }) - expect(window.location.pathname).toBe('/Dashboard/posts')📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 5c9998d2ff4f510932c7a5a6f696ad37086a6fb4 and 6b0d3e7abcd44142bbab17dd9d75d382500cc921.
📒 Files selected for processing (12)
e2e/solid-router/basic-file-based/src/routeTree.gen.ts(11 hunks)e2e/solid-router/basic-file-based/src/routes/transition/index.tsx(1 hunks)e2e/solid-router/basic-file-based/tests/transition.spec.ts(1 hunks)packages/react-router/tests/store-updates-during-navigation.test.tsx(1 hunks)packages/router-core/src/router.ts(1 hunks)packages/solid-router/src/Match.tsx(1 hunks)packages/solid-router/src/Transitioner.tsx(3 hunks)packages/solid-router/tests/link.test.tsx(4 hunks)packages/solid-router/tests/optional-path-params.test.tsx(1 hunks)packages/solid-router/tests/router.test.tsx(1 hunks)packages/solid-router/tests/store-updates-during-navigation.test.tsx(8 hunks)packages/solid-router/tests/useNavigate.test.tsx(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
- packages/router-core/src/router.ts
- e2e/solid-router/basic-file-based/src/routes/transition/index.tsx
- packages/solid-router/tests/optional-path-params.test.tsx
- packages/solid-router/tests/useNavigate.test.tsx
- packages/react-router/tests/store-updates-during-navigation.test.tsx
- packages/solid-router/src/Match.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
e2e/solid-router/basic-file-based/tests/transition.spec.tspackages/solid-router/tests/store-updates-during-navigation.test.tsxpackages/solid-router/src/Transitioner.tsxe2e/solid-router/basic-file-based/src/routeTree.gen.tspackages/solid-router/tests/link.test.tsxpackages/solid-router/tests/router.test.tsx
e2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Store end-to-end tests under the e2e/ directory
Files:
e2e/solid-router/basic-file-based/tests/transition.spec.tse2e/solid-router/basic-file-based/src/routeTree.gen.ts
packages/{react-router,solid-router}/**
📄 CodeRabbit inference engine (AGENTS.md)
Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Files:
packages/solid-router/tests/store-updates-during-navigation.test.tsxpackages/solid-router/src/Transitioner.tsxpackages/solid-router/tests/link.test.tsxpackages/solid-router/tests/router.test.tsx
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
e2e/solid-router/basic-file-based/tests/transition.spec.tspackages/solid-router/tests/store-updates-during-navigation.test.tsxe2e/solid-router/basic-file-based/src/routeTree.gen.tspackages/solid-router/tests/link.test.tsxpackages/solid-router/tests/router.test.tsx
📚 Learning: 2025-10-09T12:59:02.129Z
Learnt from: hokkyss Repo: TanStack/router PR: 5418 File: e2e/react-start/custom-identifier-prefix/src/styles/app.css:19-21 Timestamp: 2025-10-09T12:59:02.129Z Learning: In e2e test directories (paths containing `e2e/`), accessibility concerns like outline suppression patterns are less critical since the code is for testing purposes, not production use.Applied to files:
e2e/solid-router/basic-file-based/tests/transition.spec.ts
📚 Learning: 2025-10-09T12:59:14.842Z
Learnt from: hokkyss Repo: TanStack/router PR: 5418 File: e2e/react-start/custom-identifier-prefix/public/site.webmanifest:2-3 Timestamp: 2025-10-09T12:59:14.842Z Learning: In e2e test fixtures (files under e2e directories), empty or placeholder values in configuration files like site.webmanifest are acceptable and should not be flagged unless the test specifically validates those fields.Applied to files:
e2e/solid-router/basic-file-based/tests/transition.spec.ts
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Applied to files:
packages/solid-router/tests/store-updates-during-navigation.test.tsxpackages/solid-router/src/Transitioner.tsxe2e/solid-router/basic-file-based/src/routeTree.gen.tspackages/solid-router/tests/link.test.tsxpackages/solid-router/tests/router.test.tsx
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel Repo: TanStack/router PR: 5330 File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61 Timestamp: 2025-10-01T18:31:35.420Z Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.Applied to files:
e2e/solid-router/basic-file-based/src/routeTree.gen.ts
📚 Learning: 2025-09-28T21:41:45.233Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5284 File: e2e/react-start/basic/server.js:50-0 Timestamp: 2025-09-28T21:41:45.233Z Learning: In Express v5, catch-all routes must use named wildcards. Use `/*splat` to match everything except root path, or `/{*splat}` (with braces) to match including root path. The old `*` syntax is not allowed and will cause "Missing parameter name" errors. This breaking change requires explicit naming of wildcard parameters.Applied to files:
e2e/solid-router/basic-file-based/src/routeTree.gen.ts
📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel Repo: TanStack/router PR: 5330 File: packages/router-core/src/router.ts:2231-2245 Timestamp: 2025-10-01T18:30:26.591Z Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.Applied to files:
packages/solid-router/tests/router.test.tsx
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/Applied to files:
packages/solid-router/tests/router.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (1)
packages/solid-router/tests/link.test.tsx (1)
396-399: LGTM! Proper synchronization for navigation transition.The addition of
waitForensures the navigation has completed and the link has acquired the 'active' class before proceeding with subsequent assertions. This properly handles the asynchronous nature of navigation transitions.@@ -34,8 +35,13 @@3435 const isPagePending = () => isLoading() || hasPendingMatches()3536 const previousIsPagePending = usePrevious(isPagePending)363737- router.startTransition = async (fn: () => void | Promise<void>) => {38+ router.startTransition = (fn: () => void | Promise<void>) => {3839 setIsTransitioning(true)39- await fn()40- setIsTransitioning(false)40+ Solid.startTransition(async () => {41+ try {42+ await fn()43+ } finally {44+ setIsTransitioning(false)45+ }46+ })4147 }⚠️ Potential issue | 🔴 Critical
Don’t hand Solid.startTransition an async callback.
Solid’s
startTransitionexpects a synchronous callback. Giving it anasyncfunction means the awaited part runs after Solid has already ended the transition, so updates escape the transition and errors become unhandled rejections. Runfnsynchronously (capture its promise separately) and onlyawaitit outside the transition to keep semantics intact.🤖 Prompt for AI Agents
In packages/solid-router/src/Transitioner.tsx around lines 38 to 47, the code passes an async callback to Solid.startTransition which breaks transition semantics; instead call Solid.startTransition with a synchronous function that invokes fn() but does not await it, capture the returned promise in a local variable, then await that promise outside the transition in a finally block that resets setIsTransitioning(false) so the awaited work runs after Solid ends the transition and any errors can be handled properly.
⚠️ Potential issue | 🔴 Critical
Maintain startTransition’s async contract.
router.startTransitionused to resolve once the wrapped work finished. After this refactor it always returnsvoid, so any callers still doingawait router.startTransition(...)now resume immediately, which can break sequencing and letisTransitioningdrop before the work finishes. Please restore the async return (e.g. by returning thePromisefromSolid.startTransition).🤖 Prompt for AI Agents
In packages/solid-router/src/Transitioner.tsx around lines 38 to 47, router.startTransition currently returns void causing callers that await it to resume immediately; restore the async contract by returning a Promise that resolves when the wrapped work completes. Change the implementation to return the Promise from Solid.startTransition (or wrap the async work in a new Promise) so callers can await completion, ensure setIsTransitioning(true) is set before starting and setIsTransitioning(false) in finally after the awaited work, and propagate any errors to the returned Promise.packages/solid-router/tests/link.test.tsx line 4358OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -4342,4 +4355,4 @@43424355 expect(mock).toHaveBeenCalledTimes(1)43434356 })434443574345- test('Router.preload="intent", pendingComponent renders during unresolved route loader', async () => {4358+ test.skip('Router.preload="intent", pendingComponent renders during unresolved route loader', async () => {⚠️ Potential issue | 🔴 Critical
🧩 Analysis chain
Clarify why this critical test is skipped.
This test validates that
pendingComponentrenders during an unresolved route loader, which is directly related to the PR's objective of fixing navigation transitions with Suspense boundaries. Skipping it without explanation is concerning.Please explain why this test is being skipped:
- Does the new navigation transition behavior intentionally change how
pendingComponentworks? - Is this a temporary skip while the implementation is in progress?
- Does the test need to be rewritten to match the new transition behavior?
If the behavior has changed intentionally, the test should be updated rather than skipped. If there's a regression, it should be fixed before merging.
🏁 Script executed:
#!/bin/bash # Retrieve the test file content around line 4358 cat packages/solid-router/tests/link.test.tsx | sed -n '4340,4380p'Length of output: 1096
🏁 Script executed:
#!/bin/bash # Search for any context around the skipped test - look for comments explaining why sed -n '4350,4370p' packages/solid-router/tests/link.test.tsx | cat -ALength of output: 689
🏁 Script executed:
#!/bin/bash # Search for TODO, FIXME, or skip-related comments in the test file rg -n 'skip|TODO|FIXME' packages/solid-router/tests/link.test.tsx -A2 -B2 | head -50Length of output: 217
🏁 Script executed:
#!/bin/bash # Check if there are any recent changes or comments mentioning pendingComponent rg -n 'pendingComponent' packages/solid-router/tests/link.test.tsx -B3 -A3Length of output: 308
🏁 Script executed:
#!/bin/bash # Get the full implementation of the skipped test sed -n '4358,4420p' packages/solid-router/tests/link.test.tsxLength of output: 1768
🏁 Script executed:
#!/bin/bash # Search for other pendingComponent references in tests rg -n 'pendingComponent' packages/solid-router/tests/ -B2 -A2Length of output: 2016
🏁 Script executed:
#!/bin/bash # Check source code for pendingComponent implementation rg -n 'pendingComponent' packages/solid-router/src/ -B2 -A2Length of output: 1594
🏁 Script executed:
#!/bin/bash # Look for any related changes or comments about navigation transitions rg -n 'preload.*intent' packages/solid-router/tests/link.test.tsx -B3 -A3Length of output: 524
Remove
test.skip()or add explanation for why this critical test is disabled.This test validates that
pendingComponentrenders during navigation withpreload="intent", which is core to the PR's objective. The test is complete and properly implemented, yet skipped without any comment explaining why.If the behavior has intentionally changed, update the test expectations. If there's a known issue, document it with a TODO comment. If this is temporary, the test must be re-enabled before merging.
🤖 Prompt for AI Agents
In packages/solid-router/tests/link.test.tsx around line 4358, the test is marked with test.skip which disables a critical test; either re-enable the test by removing .skip, or if skipping is intentional, add a clear inline comment/TODO explaining why (linking an issue or describing expected behavioral change) and include a plan/date to restore it; if the behavior changed, update the test expectations to match the new behavior instead of skipping.✅ Addressed in commits 219b72c to cfef9e0
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/solid-router/src/useMatch.tsx (1)
76-104: Consider improving type safety of the matchState selector.The selector uses
anytypes in several places (lines 78, 81, 82, 88, 104), reducing type safety. While the logic correctly implements deferred error handling for transitions, the match and state parameters could be more strongly typed.Consider applying stronger types:
- const matchState: Solid.Accessor<{ - match: any - shouldThrowError: boolean - }> = useRouterState({ - select: (state: any) => { - const match = state.matches.find((d: any) => + type MatchState<TResult> = { + match: TResult | undefined + shouldThrowError: boolean + } + + const matchState = useRouterState({ + select: (state) => { + const match = state.matches.find((d) => opts.from ? opts.from === d.routeId : d.id === nearestMatchId(), ) if (match === undefined) { // During navigation transitions, check if the match exists in pendingMatches - const pendingMatch = state.pendingMatches?.find((d: any) => + const pendingMatch = state.pendingMatches?.find((d) => opts.from ? opts.from === d.routeId : d.id === nearestMatchId(), ) // Determine if we should throw an error const shouldThrowError = !pendingMatch && !state.isTransitioning && (opts.shouldThrow ?? true) - return { match: undefined, shouldThrowError } + return { match: undefined, shouldThrowError } as MatchState<UseMatchResult<TRouter, TFrom, TStrict, TSelected>> } return { match: opts.select ? opts.select(match) : match, shouldThrowError: false, - } + } as MatchState<UseMatchResult<TRouter, TFrom, TStrict, TSelected>> }, - } as any) + })📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between cfef9e065b8b21064895cc6337d807a376a0ed83 and dc9f86ed7529a3eeeb6b8c34ec4afceca90b988d.
📒 Files selected for processing (3)
packages/solid-router/src/Match.tsx(8 hunks)packages/solid-router/src/useMatch.tsx(1 hunks)packages/solid-router/tests/store-updates-during-navigation.test.tsx(7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/solid-router/src/Match.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/solid-router/tests/store-updates-during-navigation.test.tsxpackages/solid-router/src/useMatch.tsx
packages/{react-router,solid-router}/**
📄 CodeRabbit inference engine (AGENTS.md)
Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Files:
packages/solid-router/tests/store-updates-during-navigation.test.tsxpackages/solid-router/src/useMatch.tsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
packages/solid-router/tests/store-updates-during-navigation.test.tsx
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Applied to files:
packages/solid-router/tests/store-updates-during-navigation.test.tsxpackages/solid-router/src/useMatch.tsx
🧬 Code graph analysis (1)
packages/solid-router/src/useMatch.tsx (1)
packages/solid-router/src/useRouterState.tsx (1)
useRouterState(47-72)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
🔇 Additional comments (5)
packages/solid-router/src/useMatch.tsx (3)
86-96: Transition-aware match resolution looks correct.The logic properly handles navigation transitions by checking
pendingMatchesandisTransitioningstate before throwing errors. This enables manual Suspense boundaries to hold during navigation instead of immediately showing fallbacks, which addresses the core issue from #5636.
106-116: Error handling pattern is appropriate for Solid's reactivity model.Deferring the error throw from the selector to a
createEffectis the correct approach for Solid.js. This allows error boundaries to properly catch errors and prevents disrupting the reactive tracking system during transitions.
119-119: Return value implementation is sound.Using
createMemoto extract just the match value is the correct approach—it keeps the internal error-tracking state (shouldThrowError) from leaking into the public API while maintaining proper reactivity. Theas anyassertion is acceptable here due to TypeScript's limitations with the complex conditional return type (ThrowOrOptional<UseMatchResult<...>, TThrow>).packages/solid-router/tests/store-updates-during-navigation.test.tsx (2)
159-159: Good: Redirection in preload shows improvement.This test case shows a reduction in store updates (6→5), indicating the transition changes improved efficiency for preload redirections.
140-140: Verify that increased update counts are necessary and minimal for transition functionality.Most test expectations were increased (6 out of 9 tests), with one showing improvement (line 159: 6→5). The increases range from +1 to +2 updates per navigation:
- Line 140: 11→13 (+2)
- Line 176: 10→12 (+2)
- Line 203: 6→8 (+2)
- Line 245: 6→8 (+2)
- Line 262: 5→6 (+1)
- Line 278: 4→5 (+1)
The test file explicitly states: "This number should be as small as possible... Any change that increases this number should be investigated." While these increases are likely necessary for the transition mechanism that preserves matches during navigation, the inline comments require verification:
- Have you verified these are the minimal necessary updates for the transition mechanism?
- Has the performance impact of the increased updates been analyzed?
- Is there documented reasoning for why certain scenarios require +2 updates while others need only +1?
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 0e70efc796944aba27fb38d085535b022fb1e2e3 and f4f6160ae0358b6448d3e8c2e79d7dfc16d5cd7a.
📒 Files selected for processing (1)
packages/solid-router/src/Match.tsx(9 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/solid-router/src/Match.tsx
packages/{react-router,solid-router}/**
📄 CodeRabbit inference engine (AGENTS.md)
Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Files:
packages/solid-router/src/Match.tsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Applied to files:
packages/solid-router/src/Match.tsx
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
packages/solid-router/src/Match.tsx
🧬 Code graph analysis (1)
packages/solid-router/src/Match.tsx (2)
packages/router-core/src/route.ts (1)
AnyRoute(778-797)
packages/react-router/src/Match.tsx (1)
Match(26-146)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (4)
packages/solid-router/src/Match.tsx (4)
28-43: LGTM: Graceful null handling during navigation transitions.The null check and early return properly handle the case where matches are temporarily removed during navigation transitions, preventing downstream errors.
371-376: LGTM: Consistent null handling for parent match.The null check and graceful return of
falseproperly handles the case where the parent match is temporarily removed during navigation transitions, consistent with the pattern used elsewhere in this file.
412-430: LGTM: Proper memoization to prevent stale accessor errors.The use of
createMemoto wrapmatchIdAccessor()is a valid Solid pattern that prevents stale accessor errors while maintaining reactivity. The consistent usage ofcurrentMatchId()throughout the render logic is correct.
66-66: wrapInSuspense option is not implemented in Solid Match component.The option (defined in router-core) is respected by React but ignored by Solid. React's Match.tsx conditionally wraps routes based on
wrapInSuspense,PendingComponent, and other factors, with a SafeFragment fallback. Solid's implementation unconditionally returnsSolid.Suspense, removing the ability to opt out.No Solid tests or examples use this option, and there is no documentation explaining the intentional difference from React's behavior. Verify whether this is an intentional design decision for Solid's reactivity model or an incomplete implementation that should match React's opt-in/opt-out behavior.
packages/solid-router/src/Match.tsx line 45Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -37,4 +39,7 @@3739 },3840 })394140- const route: () => AnyRoute = () => router.routesById[matchState().routeId]42+ // If match doesn't exist yet, return null (component is being unmounted or not ready)43+ if (!matchState()) return null44+45+ const route: () => AnyRoute = () => router.routesById[matchState()!.routeId]⚠️ Potential issue | 🔴 Critical
🧩 Analysis chain
Verify route lookup safety.
The route lookup assumes
router.routesById[matchState()!.routeId]always returns a valid route. If therouteIddoesn't exist inroutesById, this will returnundefined, causing runtime errors in downstream code that callsroute().Run the following script to verify how routes are registered and whether this lookup can fail:
🏁 Script executed:
#!/bin/bash # Description: Check if route registration guarantees routeId exists in routesById # Search for routesById assignments and usage patterns rg -nP 'routesById\[' --type=ts -A2 -B2 # Look for route registration logic rg -nP 'class.*Router|registerRoute|addRoute' --type=ts -A5Length of output: 18224
I need to verify the type safety and guarantees around the route lookup. Let me search for the type definition of
routesByIdand understand the data flow.I need to check the actual type definition of
routesByIdto confirm whether the lookup can returnundefined.Now let me search in the codebase to find the actual type definition of
routesByIdto confirm the type signature.[/run_scripts]
🏁 Script executed:
#!/bin/bash # Search for routesById type definition in router.ts rg -nP 'routesById\s*[:=]' --type=ts -B2 -A2 packages/router-core/src/router.ts | head -50 # Also check if there's an interface or type definition rg -nP 'type.*routesById|interface.*routesById' --type=ts -A3Length of output: 641
Let me search for how
matchStateis populated to understand if therouteIdis guaranteed to exist inroutesById.[/run_scripts]
🏁 Script executed:
#!/bin/bash # Search for matchState definition and population rg -nP 'matchState.*=' --type=ts -B3 -A3 packages/solid-router/src/Match.tsx | head -80 # Also check router state/match state type definitions rg -nP 'RouteMatch|MatchState' --type=ts -B2 -A5 packages/router-core/src/router.ts | head -60Length of output: 2476
Based on my analysis of the codebase, I found a clear pattern inconsistency that supports the review comment:
Add non-null assertion for type consistency:
Lines 225 and 365 in the same file explicitly assert non-null on the
routesByIdlookup:- Line 225:
const route = () => router.routesById[matchState()!.routeId]! - Line 365:
const route = () => router.routesById[routeId()]!
Line 45 follows the same pattern but lacks the
!assertion despite declaring a non-nullable return type() => AnyRoute. While the logic suggests a match ins.matchesshould have a corresponding route inroutesById, TypeScript doesn't enforce this guarantee at the type level. Add the assertion for consistency and clarity:- const route: () => AnyRoute = () => router.routesById[matchState()!.routeId] + const route: () => AnyRoute = () => router.routesById[matchState()!.routeId]!📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const route: () => AnyRoute = () => router.routesById[matchState()!.routeId]!🤖 Prompt for AI Agents
In packages/solid-router/src/Match.tsx around line 45, the route lookup uses router.routesById[matchState()!.routeId] but lacks the non-null assertion used elsewhere; make this lookup consistent by appending a `!` (router.routesById[matchState()!.routeId]!) so the returned value matches the declared non-nullable return type () => AnyRoute and satisfies TypeScript's expectations.✅ Addressed in commits f96697a to a37c72d
packages/solid-router/src/Match.tsx line 224Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -218,4 +219,7 @@218219 },219220 })220221221- const route = () => router.routesById[matchState().routeId]!222+ // If match doesn't exist yet, return null223+ if (!matchState()) return null224+225+ const route = () => router.routesById[matchState()!.routeId]!⚠️ Potential issue | 🔴 Critical
Critical: Unsafe double non-null assertion.
Line 225 uses two non-null assertions:
router.routesById[matchState()!.routeId]!. While the first assertion onmatchState()is safe (protected by the null check on line 223), the second assertion on the route lookup is risky. IfrouteIddoesn't exist inroutesById, this will cause a runtime error at the call site ofroute().Consider adding defensive handling:
-const route = () => router.routesById[matchState()!.routeId]! +const route = () => { + const r = router.routesById[matchState()!.routeId] + if (!r) { + console.error(`Route not found for routeId: ${matchState()!.routeId}`) + return null + } + return r +}Or, if routes are guaranteed to exist by design, verify this invariant is maintained throughout the codebase.
Committable suggestion skipped: line range outside the PR's diff.
✅ Addressed in commits f96697a to a37c72d
@@ -287,4 +291,18 @@287291 return router.getMatch(match().id)?._nonReactive.loadPromise288292 })289293294+ // Display pending component if defined295+ const pendingComponent =296+ route().options.pendingComponent ??297+ router.options.defaultPendingComponent298+299+ if (pendingComponent) {300+ return (301+ <>302+ <Dynamic component={pendingComponent} />303+ {loaderResult()}304+ </>305+ )306+ }307+290308 return <>{loaderResult()}</>⚠️ Potential issue | 🔴 Critical
Critical: Simultaneous rendering of pending and loaded content.
Lines 299-306 render both the
pendingComponentandloaderResult()simultaneously:<> <Dynamic component={pendingComponent} /> {loaderResult()} </>This appears to be a logic error. Typically, you'd show the pending component while loading, then replace it with the loaded content. Here, both are rendered at the same time once the loader completes.
If
loaderResult()suspends during loading (viacreateResource), the outerSuspenseboundary should already handle showing the pending component, making this redundant. IfloaderResult()doesn't suspend, then showing both components doesn't make UX sense.Consider one of these approaches:
Option 1: Let Suspense handle pending state (remove redundant pending component)
-// Display pending component if defined -const pendingComponent = - route().options.pendingComponent ?? - router.options.defaultPendingComponent - -if (pendingComponent) { - return ( - <> - <Dynamic component={pendingComponent} /> - {loaderResult()} - </> - ) -} - return <>{loaderResult()}</>Option 2: Explicitly handle loading state (if loaderResult doesn't suspend)
-if (pendingComponent) { - return ( - <> - <Dynamic component={pendingComponent} /> - {loaderResult()} - </> - ) -} +return ( + <Solid.Show when={!loaderResult.loading} fallback={pendingComponent ? <Dynamic component={pendingComponent} /> : null}> + {loaderResult()} + </Solid.Show> +)🤖 Prompt for AI Agents
In packages/solid-router/src/Match.tsx around lines 294 to 308, the code currently renders both the pendingComponent and loaderResult() at the same time, which is incorrect; change the logic so pendingComponent is shown only while loading and replaced by loaderResult() once loaded. Either remove the manual pendingComponent render and rely on the outer Suspense (i.e. return only loaderResult() here), or explicitly detect the loader's loading state (or resource pending state) and return the pendingComponent when loading and loaderResult() when finished; update the conditional to choose one branch (pending OR loaded) not both.Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/solid-router/src/Match.tsx (2)
28-105: Early null guard still crashes when the match briefly disappearsReturning
nullthe momentmatchState()is falsy only affects the very first invocation of this component. During a transition the router can temporarily drop the match (the scenario this PR is trying to support), somatchState()later flips tonull. Because the component body doesn’t re-run, every closure we created below (route(),resolvePendingComponent(),routeNotFoundComponent(), …) still dereferencesmatchState()!.routeIdand we blow up withTypeError: Cannot read properties of null (reading 'routeId')as soon as the reproduction from #5636 navigates while a loader is pending.We need to make the guard reactive—either wrap the whole render tree in a
<Show when={matchState()}>and define the dependent helpers inside, or rework each helper to tolerateundefined(return early before touching.routeId). For example:- if (!matchState()) return null - - const route: () => AnyRoute = () => - router.routesById[matchState()!.routeId] + const state = Solid.createMemo(matchState) + + return ( + <Solid.Show when={state()} fallback={null}> + {(current) => { + const route = () => router.routesById[current().routeId]! + // …rest of the logic that currently lives below + }} + </Solid.Show> + )Without moving the rest of the logic under a reactive guard we still crash under the manual Suspense transition, so this is a blocker.
186-352: MatchInner has the same unsafe guardThe same early-return pattern shows up here:
if (!matchState()) return nullonly protects the initial mount. Once the router briefly removes the match, every helper below (route(),match(),componentKey(), thependingbranch that readsroute().options…, etc.) still closes overmatchState()!.…and throws. You can hit this by running the linked Suspense repro and navigating during a pending transition—the stack trace now originates fromMatchInner.Please restructure this component the same way as
Match: gate the rest of the logic behind a reactive guard (e.g. a<Show when={matchState()}>block) or make each helper tolerateundefinedbefore touching the match. Until we do that, navigation transitions still crash, so we can’t ship this.🧹 Nitpick comments (1)
e2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsx (1)
32-34: Remove redundantcreateMemowrapper.useQueryalready returns a reactive signal in Solid, so wrapping it increateMemois unnecessary and adds overhead.- const doubleQuery = createMemo(() => - useQuery(() => doubleQueryOptions(search().n)), - ) + const doubleQuery = useQuery(() => doubleQueryOptions(search().n))Update line 50 to:
- <div data-testid="double-value">double: {doubleQuery().data}</div> + <div data-testid="double-value">double: {doubleQuery.data}</div>📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between a37c72d61860e3f88492e37c7eb9f3a66535ab0b and e0364bb98fb531e5a7ece9f05918e662789343ed.
📒 Files selected for processing (5)
e2e/solid-router/basic-file-based/tests/transition.spec.ts(1 hunks)e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts(9 hunks)e2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsx(1 hunks)e2e/solid-router/basic-solid-query-file-based/tests/transition.spec.ts(1 hunks)packages/solid-router/src/Match.tsx(11 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- e2e/solid-router/basic-file-based/tests/transition.spec.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
e2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsxe2e/solid-router/basic-solid-query-file-based/tests/transition.spec.tse2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.tspackages/solid-router/src/Match.tsx
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
e2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsx
e2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Store end-to-end tests under the e2e/ directory
Files:
e2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsxe2e/solid-router/basic-solid-query-file-based/tests/transition.spec.tse2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts
packages/{react-router,solid-router}/**
📄 CodeRabbit inference engine (AGENTS.md)
Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Files:
packages/solid-router/src/Match.tsx
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Applied to files:
e2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsxe2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.tspackages/solid-router/src/Match.tsx
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
e2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsxe2e/solid-router/basic-solid-query-file-based/tests/transition.spec.tse2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.tspackages/solid-router/src/Match.tsx
📚 Learning: 2025-10-14T18:59:33.990Z
Learnt from: FatahChan Repo: TanStack/router PR: 5475 File: e2e/react-start/basic-prerendering/src/routes/redirect/$target/via-beforeLoad.tsx:8-0 Timestamp: 2025-10-14T18:59:33.990Z Learning: In TanStack Router e2e test files, when a route parameter is validated at the route level (e.g., using zod in validateSearch or param validation), switch statements on that parameter do not require a default case, as the validation ensures only expected values will reach the switch.Applied to files:
e2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsxpackages/solid-router/src/Match.tsx
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel Repo: TanStack/router PR: 5330 File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61 Timestamp: 2025-10-01T18:31:35.420Z Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.Applied to files:
e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to **/src/routes/** : Place file-based routes under src/routes/ directoriesApplied to files:
e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts
📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel Repo: TanStack/router PR: 5330 File: packages/router-core/src/router.ts:2231-2245 Timestamp: 2025-10-01T18:30:26.591Z Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.Applied to files:
packages/solid-router/src/Match.tsx
🧬 Code graph analysis (2)
e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts (1)
e2e/solid-router/basic-file-based/src/routeTree.gen.ts (1)
FileRoutesByTo(667-747)
packages/solid-router/src/Match.tsx (3)
packages/router-core/src/route.ts (1)
AnyRoute(778-797)
packages/router-core/src/index.ts (2)
AnyRoute(162-162)rootRouteId(110-110)
packages/react-router/src/Match.tsx (1)
Match(26-146)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (1)
e2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsx (1)
6-55: Excellent demonstration of navigation transition handling.The implementation correctly uses
placeholderData: (oldData) => oldData(line 17) to preserve previous query data during navigation, which prevents the Suspense fallback from triggering. Combined withensureQueryDatain the loader, this achieves smooth transitions where the old content remains visible while new data loads.@@ -0,0 +16,21 @@16+ .textContent()17+ .catch(() => '')18+ if (text) bodySnapshots.push(text)19+ }, 50)20+21+ await page.getByTestId('increase-button').click()22+23+ await page.waitForTimeout(200)24+25+ clearInterval(interval)26+27+ await expect(page.getByTestId('n-value')).toContainText('n: 2', {28+ timeout: 2_000,29+ })30+ await expect(page.getByTestId('double-value')).toContainText('double: 4', {31+ timeout: 2_000,32+ })33+34+ const sawLoading = bodySnapshots.some((text) => text.includes('Loading...'))35+36+ expect(sawLoading).toBeFalsy()⚠️ Potential issue | 🔴 Critical
Critical flaw in test timing logic.
The interval stops capturing snapshots at 200ms (line 25), but the expectations wait up to 2 seconds for updated values (lines 27-32). If the "Loading..." fallback appears between 200ms and when the values actually update, the test won't detect it—creating a false positive.
Move
clearInterval(interval)to after the final expectations to ensure the entire transition period is monitored:- await page.waitForTimeout(200) - - clearInterval(interval) - await expect(page.getByTestId('n-value')).toContainText('n: 2', { timeout: 2_000, }) await expect(page.getByTestId('double-value')).toContainText('double: 4', { timeout: 2_000, }) + + clearInterval(interval) const sawLoading = bodySnapshots.some((text) => text.includes('Loading...'))📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const bodySnapshots: Array<string> = [] const interval = setInterval(async () => { const text = await page .locator('body') .textContent() .catch(() => '') if (text) bodySnapshots.push(text) }, 50) await page.getByTestId('increase-button').click() await expect(page.getByTestId('n-value')).toContainText('n: 2', { timeout: 2_000, }) await expect(page.getByTestId('double-value')).toContainText('double: 4', { timeout: 2_000, }) clearInterval(interval) const sawLoading = bodySnapshots.some((text) => text.includes('Loading...')) expect(sawLoading).toBeFalsy()🤖 Prompt for AI Agents
In e2e/solid-router/basic-solid-query-file-based/tests/transition.spec.ts around lines 11 to 36, the snapshot-capturing interval is cleared before the test waits (and retries) for the final values, so any transient "Loading..." state that occurs after 200ms but before the expectations resolve will be missed; move clearInterval(interval) to after the final expect checks (i.e., after the two toContainText awaits and just before asserting sawLoading) so the interval continues recording for the entire timeout window.@@ -0,0 +5,21 @@5+}) => {6+ await page.goto('/transition')7+8+ await expect(page.getByTestId('n-value')).toContainText('n: 1')9+ await expect(page.getByTestId('double-value')).toContainText('double: 2')10+11+ const bodySnapshots: Array<string> = []12+13+ const interval = setInterval(async () => {14+ const text = await page15+ .locator('body')16+ .textContent()17+ .catch(() => '')18+ if (text) bodySnapshots.push(text)19+ }, 50)20+21+ await page.getByTestId('increase-button').click()22+23+ await page.waitForTimeout(200)24+25+ clearInterval(interval)⚠️ Potential issue | 🟠 Major
Add cleanup for interval to prevent resource leak.
If the test fails or times out before line 25,
setIntervalwill continue running. Wrap the interval logic in a try-finally block or use Playwright's test.afterEach for cleanup.+ let interval: NodeJS.Timeout | undefined + - const interval = setInterval(async () => { + try { + interval = setInterval(async () => { + const text = await page + .locator('body') + .textContent() + .catch(() => '') + if (text) bodySnapshots.push(text) + }, 50) + + await page.getByTestId('increase-button').click() + + await expect(page.getByTestId('n-value')).toContainText('n: 2', { + timeout: 2_000, + }) + await expect(page.getByTestId('double-value')).toContainText('double: 4', { + timeout: 2_000, + }) + } finally { + if (interval) clearInterval(interval) + } - const text = await page - .locator('body') - .textContent() - .catch(() => '') - if (text) bodySnapshots.push(text) - }, 50) - - await page.getByTestId('increase-button').click() - - clearInterval(interval) - - await expect(page.getByTestId('n-value')).toContainText('n: 2', { - timeout: 2_000, - }) - await expect(page.getByTestId('double-value')).toContainText('double: 4', { - timeout: 2_000, - })Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In e2e/solid-router/basic-solid-query-file-based/tests/transition.spec.ts around lines 13 to 25, the setInterval created to poll page body content is not guaranteed to be cleared if the test fails or times out; wrap the interval logic so it is always cleaned up—for example, create the interval, run the async test actions inside a try block, and call clearInterval(interval) in a finally block, or register clearInterval with Playwright's test.afterEach cleanup (or test.addCleanup) so the interval is always cleared even on failure/timeouts.Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between e0364bb98fb531e5a7ece9f05918e662789343ed and ca69d40825888e54a32c9d576227bdac9e8678fe.
📒 Files selected for processing (3)
e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts(9 hunks)e2e/react-router/basic-react-query-file-based/src/routes/transition/index.tsx(1 hunks)e2e/react-router/basic-react-query-file-based/tests/transition.spec.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
e2e/react-router/basic-react-query-file-based/tests/transition.spec.tse2e/react-router/basic-react-query-file-based/src/routes/transition/index.tsxe2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts
e2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Store end-to-end tests under the e2e/ directory
Files:
e2e/react-router/basic-react-query-file-based/tests/transition.spec.tse2e/react-router/basic-react-query-file-based/src/routes/transition/index.tsxe2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
e2e/react-router/basic-react-query-file-based/src/routes/transition/index.tsx
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/Learnt from: FatahChan Repo: TanStack/router PR: 5475 File: e2e/react-start/basic-prerendering/src/routes/redirect/$target/via-beforeLoad.tsx:8-0 Timestamp: 2025-10-14T18:59:33.990Z Learning: In TanStack Router e2e test files, when a route parameter is validated at the route level (e.g., using zod in validateSearch or param validation), switch statements on that parameter do not require a default case, as the validation ensures only expected values will reach the switch.📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
e2e/react-router/basic-react-query-file-based/tests/transition.spec.tse2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel Repo: TanStack/router PR: 5330 File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61 Timestamp: 2025-10-01T18:31:35.420Z Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.Applied to files:
e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to **/src/routes/** : Place file-based routes under src/routes/ directoriesApplied to files:
e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Applied to files:
e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts
🧬 Code graph analysis (1)
e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts (1)
e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts (1)
FileRoutesByTo(75-82)
🪛 Biome (2.1.2)
e2e/react-router/basic-react-query-file-based/src/routes/transition/index.tsx
[error] 33-33: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order. See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
e2e/react-router/basic-react-query-file-based/src/routes/transition/index.tsx lines 32 to 35OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +15,21 @@15+ return n * 216+ },17+ placeholderData: (oldData) => oldData,18+ })19+20+export const Route = createFileRoute('/transition/')({21+ validateSearch: searchSchema,22+ loader: ({ context: { queryClient }, location }) => {23+ const { n } = searchSchema.parse(location.search)24+ return queryClient.ensureQueryData(doubleQueryOptions(n))25+ },26+ component: TransitionPage,27+})28+29+function TransitionPage() {30+ const search = Route.useSearch()31+32+ const doubleQuery = useMemo(33+ () => useQuery(doubleQueryOptions(search.n)),34+ [search.n],35+ )⚠️ Potential issue | 🔴 Critical
Fix hook usage: call
useQueryat the top level.Wrapping
useQueryinsideuseMemomeans React will skip theuseQuerycall wheneversearch.nhasn’t changed, breaking hook ordering and causing runtime errors. CalluseQuerydirectly at the component level (optionally memoize only the options object) so the hook runs on every render in a consistent order.- const doubleQuery = useMemo( - () => useQuery(doubleQueryOptions(search.n)), - [search.n], - ) + const doubleQuery = useQuery(doubleQueryOptions(search.n))📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const doubleQuery = useQuery(doubleQueryOptions(search.n))🧰 Tools
🪛 Biome (2.1.2)
[error] 33-33: This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.
For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order. See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
(lint/correctness/useHookAtTopLevel)
🤖 Prompt for AI Agents
In e2e/react-router/basic-react-query-file-based/src/routes/transition/index.tsx around lines 32 to 35, the code currently calls useQuery inside useMemo which breaks React hook ordering; change it to call useQuery directly at the top level of the component (so the hook runs every render in a consistent order) and, if you need to avoid recreating the options object, memoize only the options with useMemo/useCallback using [search.n] as the dependency, then pass that memoized options object into useQuery.✅ Addressed in commit 5ff886c
birkskyum(GitHub profile, opens in a new tab) changed the title
birkskyum(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Walkthrough#
Adds a new
/transitionfile-based route and Playwright e2e tests across multiple examples; rewires generated route trees. Refactors router core and solid-router transition batching, match resolution, and useMatch error timing to tolerate in-flight navigations and preserve UI during transitions.Changes#
e2e/solid-router/basic-file-based/src/routes/transition/index.tsx,e2e/solid-router/basic-file-based/src/routeTree.gen.ts/transitionroute, search validation (n:number default 1), Suspense-backed component, and wires the route into generated route tree and public route maps.e2e/solid-router/basic-file-based/tests/transition.spec.tse2e/solid-router/basic-solid-query-file-based/src/routes/transition/index.tsx,e2e/solid-router/basic-solid-query-file-based/src/routeTree.gen.ts/transitionroute with solid-query loader & placeholderData, wires into generated route tree and public maps.e2e/solid-router/basic-solid-query-file-based/tests/transition.spec.tse2e/react-router/basic-react-query-file-based/src/routes/transition/index.tsx,e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts/transitionReact route with react-query loader/placeholderData and updates generated route tree and public typings.e2e/react-router/basic-react-query-file-based/tests/transition.spec.tspackages/router-core/src/router.tspackages/solid-router/src/Transitioner.tsxpackages/solid-router/src/Match.tsxpackages/solid-router/src/useMatch.tsxpackages/solid-router/tests/*,packages/react-router/tests/*Sequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~45 minutes
Points to focus review on:
packages/router-core/src/router.ts.packages/solid-router/src/Transitioner.tsx.packages/solid-router/src/Match.tsx(SSR/hydration edge cases).packages/solid-router/src/useMatch.tsx.Possibly related PRs#
Suggested reviewers#
Poem#
Pre-merge checks and finishing touches#
✅ Passed checks (4 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.
❤️ Share