fix(router-core): handle rejected promise in loadRouteChunk #6645
main fromrefs/pull/6645/head·opened Summary#
loadRouteChunk calls route.lazyFn() without a .catch(), creating an unhandled promise rejection when the dynamic import fails (e.g. network error, stale chunk after deploy).
This is harmless to end users because lazyRouteComponent independently retries and recovers via window.location.reload(), but the unhandled rejection floods error monitoring tools (Sentry, etc.) with noise.
Fixes #6107
What this PR does#
Adds a .catch() handler to the lazyFn() promise chain in loadRouteChunk that:
- Marks the rejection as handled — prevents
unhandledrejectionevents - Clears
_lazyPromise— allows the route to be retried on the next navigation attempt
What this PR does NOT do#
- Does not re-throw the error (unsafe —
_lazyPromiseis consumed via.then()at L1016 inloadRouteChunkComponents, which would create a new unhandled rejection) - Does not change match status to
'error'— preserving existing behavior wherelazyRouteComponent's auto-reload handles recovery - Does not modify any other code paths
Why .catch() only (no re-throw)?#
_lazyPromise is consumed in two places:
- L683:
await route._lazyPromise— inside try/catch, can handle rejections ✓ - L1016:
route._lazyPromise.then(loadComponents)— no.catch(), re-throwing would create a new unhandled rejection ✗
The minimal .catch() approach handles the rejection without introducing new failure modes.
Testing#
- Added 2 new tests (33 total, all passing):
- Verifies no
unhandledrejectionwhenlazyFnfails +_lazyPromisecleanup - Verifies normal success path still works correctly
- Verifies no
Summary by CodeRabbit#
Bug Fixes
- Improved error handling for lazy-loaded routes: failed lazy loads now clear their failed state, avoid unhandled promise rejections, and can be retried on subsequent navigation attempts.
Tests
- Added comprehensive tests covering lazy route loading success, failure, and retry flows to ensure proper state reset, error handling, and component resolution.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/router-core/src/load-matches.ts`: - Around line 985-989: The catch block that currently only clears route._lazyPromise should also reset route._componentsLoaded = false and route._componentsPromise = undefined to allow retries, and then rethrow the caught error so the promise chain doesn't continue into the subsequent .then(loadComponents) path; update the .catch(() => { ... }) handler to restore those route fields (route._lazyPromise, route._componentsLoaded, route._componentsPromise) and throw the original error.🧹 Nitpick comments (1)
packages/router-core/tests/load.test.ts (1)
804-847: Consider adding a retry-after-failure test to catch the_componentsLoadedstale-state bug.This test verifies the unhandled rejection is suppressed and
_lazyPromiseis cleared, but it doesn't verify that a subsequent call toloadRouteChunk(simulating retry with a succeedinglazyFn) actually works end-to-end. Given the_componentsLoadedissue noted in the source, a retry test would have caught it.Also consider asserting
(fooRoute as any)._componentsLoadedisfalseafter the failed load to ensure full cleanup.packages/router-core/src/load-matches.ts lines 1008 to 1012Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -976,7 +976,14 @@976- route._lazyPromise = route.lazyFn().then((lazyRoute) => {977- // explicitly don't copy over the lazy route's id978- const { id: _id, ...options } = lazyRoute.options979- Object.assign(route.options, options)980- route._lazyLoaded = true981- route._lazyPromise = undefined // gc promise, we won't need it anymore982- })976+ route._lazyPromise = route977+ .lazyFn()978+ .then((lazyRoute) => {979+ // explicitly don't copy over the lazy route's id980+ const { id: _id, ...options } = lazyRoute.options981+ Object.assign(route.options, options)982+ route._lazyLoaded = true983+ route._lazyPromise = undefined // gc promise, we won't need it anymore984+ })985+ .catch(() => {986+ // Handle the rejection to prevent `unhandledrejection`.987+ // Clear `_lazyPromise` so the route can be retried on next navigation.988+ route._lazyPromise = undefined989+ })⚠️ Potential issue | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
cat -n packages/router-core/src/load-matches.ts | sed -n '970,1020p'Repository: TanStack/router
Length of output: 2204
🏁 Script executed:
rg -A 3 -B 3 'route\._componentsLoaded = true' packages/router-core/src/load-matches.tsRepository: TanStack/router
Length of output: 421
🏁 Script executed:
rg 'route\._componentsLoaded' packages/router-core/src/load-matches.tsRepository: TanStack/router
Length of output: 212
🏁 Script executed:
rg -B 5 -A 5 '_lazyPromise = undefined' packages/router-core/src/load-matches.tsRepository: TanStack/router
Length of output: 662
🏁 Script executed:
# Check if there are any tests that verify retry behavior for lazy loading rg -l 'loadRouteChunk.*retry|retry.*loadRouteChunk|_lazyPromise.*retry' packages/Repository: TanStack/router
Length of output: 98
🏁 Script executed:
# Check if _componentsPromise is used elsewhere in the file rg '_componentsPromise' packages/router-core/src/load-matches.tsRepository: TanStack/router
Length of output: 491
🏁 Script executed:
# Check the test file for any lazy loading failure/retry tests grep -n -A 10 -B 5 'lazy.*fail\|fail.*lazy\|retry.*lazy' packages/router-core/tests/load.test.ts | head -60Repository: TanStack/router
Length of output: 1147
🏁 Script executed:
# Get the full test for lazy loading failure sed -n '804,847p' packages/router-core/tests/load.test.tsRepository: TanStack/router
Length of output: 1511
🏁 Script executed:
# Check if there's a test for retry behavior after failure grep -n -A 20 'retry.*lazy\|lazy.*retry\|fail.*retry' packages/router-core/tests/load.test.tsRepository: TanStack/router
Length of output: 792
🏁 Script executed:
# Check the whole test file around the loadRouteChunk tests for any retry patterns sed -n '849,900p' packages/router-core/tests/load.test.tsRepository: TanStack/router
Length of output: 1104
🏁 Script executed:
# Check if _componentsLoaded is set anywhere else rg -n '_componentsLoaded\s*=' packages/router-core/src/load-matches.tsRepository: TanStack/router
Length of output: 146
🏁 Script executed:
# Look for any initialization of _componentsLoaded rg -n '_componentsLoaded' packages/router-core/src/ --type ts --type tsx | head -20Repository: TanStack/router
Length of output: 86
🏁 Script executed:
# Check for _componentsLoaded initialization or declaration rg '_componentsLoaded' packages/router-core/src/ -t ts | head -30Repository: TanStack/router
Length of output: 399
🏁 Script executed:
# Check how _componentsLoaded is used in the route definition rg -n '_componentsLoaded' packages/router-core/src/route.tsRepository: TanStack/router
Length of output: 92
🏁 Script executed:
# Verify the exact behavior: trace through what happens when lazyFn fails # Check if loadComponents would actually execute with an unresolved lazyFn rg -B 10 -A 10 'route._lazyPromise ?' packages/router-core/src/load-matches.ts | grep -A 20 'route._componentsPromise'Repository: TanStack/router
Length of output: 1921
🏁 Script executed:
# Final check: see the complete context around lines 1014-1018 sed -n '1008,1018p' packages/router-core/src/load-matches.tsRepository: TanStack/router
Length of output: 456
Bug:
_componentsLoadednot reset on lazy load failure — retry won't preload components.When
lazyFnfails, the.catch()handler (lines 985-989) suppresses the rejection without rethrowing, allowing the promise chain to resolve. This causes the chained.then(loadComponents)(line 1015) to execute, which setsroute._componentsLoaded = true(lines 1007, 1010). On a subsequent retry, the component-loading block (line 998) is skipped because_componentsLoadedis alreadytrue, preventing components from being preloaded.Reset
_componentsLoadedand_componentsPromisein the catch handler.Proposed fix
.catch(() => { // Handle the rejection to prevent `unhandledrejection`. // Clear `_lazyPromise` so the route can be retried on next navigation. route._lazyPromise = undefined + route._componentsLoaded = false + route._componentsPromise = undefined })🤖 Prompt for AI Agents
In `@packages/router-core/src/load-matches.ts` around lines 985 - 989, The catch block that currently only clears route._lazyPromise should also reset route._componentsLoaded = false and route._componentsPromise = undefined to allow retries, and then rethrow the caught error so the promise chain doesn't continue into the subsequent .then(loadComponents) path; update the .catch(() => { ... }) handler to restore those route fields (route._lazyPromise, route._componentsLoaded, route._componentsPromise) and throw the original error.✅ Confirmed as addressed by @zhuangya
Good catch — you're right that the
.catch()converting the rejected promise to resolved causes.then(loadComponents)to execute, incorrectly setting_componentsLoaded = true.However, the proposed fix of resetting
_componentsLoadedinside the.catch()handler would not work due to timing:.catch()runs first, then.then(loadComponents)runs and overwrites the reset.Instead, I've added a
_lazyLoadedguard in the.then()callback soloadComponentsonly runs when lazy options were actually loaded. When the guard fails,_componentsPromiseis also cleared so both blocks can retry on next navigation.Added a retry test that verifies the full fail→recover cycle.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash # Check if the retry test mentioned by the user exists rg -n "retry" packages/router-core/tests/load.test.ts | head -20Length of output: 263
@zhuangyaExcellent fix! You're absolutely right about the timing issue — resetting_componentsLoadedin the.catch()handler would be immediately overwritten by the subsequent.then(loadComponents)call.Your solution using the
_lazyLoadedguard is spot-on:- When
lazyFnfails, the.catch()clears_lazyPromisebut_lazyLoadedremainsfalse - The chained
.then()checksif (route._lazyLoaded)before callingloadComponents() - Since
_lazyLoadedisfalse, it skips component loading and clears_componentsPromise - This prevents
_componentsLoadedfrom being incorrectly set totrue - On retry, both blocks can execute since both promises are cleared
The retry test at line 888 confirms this behavior works correctly. Great work addressing this edge case! 🎉
🧬 Code Graph Analysis Results
[relevant_snippets]
File: packages/router-core/src/load-matches.ts
Summary (docstring-style) Purpose: Handles loading of route components and their lazy preloads with guards.
Key behavior relevant to the user comment:
- Keeps track of two asynchronous pathways for loading components:
- route._lazyPromise / route._lazyLoaded: controls resolution of lazy-loaded route options.
- route._componentsPromise / route._componentsLoaded: controls loading of component types (component, errorComponent, pendingComponent, notFoundComponent).
- loadRouteChunk ensures:
- If a route has a lazyFn, it fetches and merges the lazy route options, marks _lazyLoaded, and clears _lazyPromise for GC; on rejection, clears _lazyPromise to allow retry on next navigation.
- If there are components to preload (via _componentsPromise or _componentsLoaded), it will trigger loading of each component type (component, errorComponent, pendingComponent, notFoundComponent) by calling their preload functions if present, and marks _componentsLoaded when done, clearing _componentsPromise for GC.
- The user-proposed fix involves:
- Introducing a _lazyLoaded guard to ensure loadComponents only runs when lazy options were actually loaded.
- Clearing route._componentsPromise when lazy loading fails, allowing a retry on next navigation.
- This function coordinates the above so that the loader/preview path and the component preloads don’t prematurely set the loaded flags, and so that a failed lazy load does not permanently mark components as loaded.
Content to reference for understanding integration points (summary; exact code not included due to length):
The section that defines:
- if (!route._lazyLoaded && route._lazyPromise === undefined) { ... }
- route._lazyPromise = route.lazyFn().then(...).catch(...)
- The handling of route._componentsPromise with a loadComponents() inner function
- The guard route._lazyPromise ? route._lazyPromise.then(() => { if (route._lazyLoaded) return loadComponents() ... }) : loadComponents()
The behavior described above is what the user’s comment targets:
- _lazyLoaded guard prevents run of loadComponents unless lazy options actually loaded
- Clearing _componentsPromise when lazy load fails enables a retry
Location: packages/router-core/src/load-matches.ts (Note: Please inspect the loadRouteChunk function to map the described guards and promise wiring to the actual code paths.)
- Keeps track of two asynchronous pathways for loading components:
File: packages/router-core/src/utils/batch.ts
Original snippet (complete) At lines 8-18:
Code: export function batch(fn: () => T): T { if (isServer) { return fn() }
let result!: T storeBatch(() => { result = fn() }) return result }
Purpose: Batches state updates to avoid intermediate reactive noise, used around loader state updates.
File: packages/router-core/src/utils.ts
isPromise function (complete snippet) At lines 488-496:
- Code: export function isPromise( value: Promise<Awaited> | T, ): value is Promise<Awaited> { return Boolean( value && typeof value === 'object' && typeof (value as Promise).then === 'function', ) }
createControlledPromise function (complete snippet) At lines 446-470:
Code: export function createControlledPromise(onResolve?: (value: T) => void) { let resolveLoadPromise!: (value: T) => void let rejectLoadPromise!: (value: any) => void
const controlledPromise = new Promise((resolve, reject) => { resolveLoadPromise = resolve rejectLoadPromise = reject }) as ControlledPromise
controlledPromise.status = 'pending'
controlledPromise.resolve = (value: T) => { controlledPromise.status = 'resolved' controlledPromise.value = value resolveLoadPromise(value) onResolve?.(value) }
controlledPromise.reject = (e) => { controlledPromise.status = 'rejected' rejectLoadPromise(e) }
return controlledPromise }
These snippets provide:
- The exact utilities that underpin promise handling and batching, which are relevant to diagnosing the interaction between lazy loading, component loading, and retry behavior described in the user comment.
- The broader loading-matches behavior referenced by the user (via load-matches.ts), specifically how lazy loading and component loading are coordinated and retried.
🧠 Learnings used
Learnt from: hokkyss Repo: TanStack/router PR: 6394 File: e2e/react-start/server-functions/src/routes/function-method/index.tsx:93-95 Timestamp: 2026-01-17T08:01:35.654Z Learning: In TanStack Router e2e server function test files (e.g., files in `e2e/react-start/server-functions`, `e2e/solid-start/server-functions`, `e2e/vue-start/server-functions`), unhandled promise rejections in server function calls (e.g., `fn().then(setResult)` without `.catch()`) are intentional test behavior to make test failures visible in the test runner, consistent with existing patterns like in `e2e/react-start/server-functions/src/routes/factory/index.tsx`.
Learnt from: Sheraff Repo: TanStack/router PR: 6171 File: packages/router-core/src/new-process-route-tree.ts:898-898 Timestamp: 2025-12-21T12:52:35.231Z Learning: In `packages/router-core/src/new-process-route-tree.ts`, the matching logic intentionally allows paths without trailing slashes to match index routes with trailing slashes (e.g., `/a` can match `/a/` route), but not vice-versa (e.g., `/a/` cannot match `/a` layout route). This is implemented via the condition `!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX` and is a deliberate design decision to provide better UX by being permissive with missing trailing slashes.
Learnt from: schiller-manuel Repo: TanStack/router PR: 6120 File: packages/router-generator/src/generator.ts:654-657 Timestamp: 2025-12-17T02:17:55.086Z Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
- When
@coderabbitai review
✅ Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
View your CI Pipeline Execution ↗ for commit 5ebfd2a9b5e304dc4317e5f91a9c4c945cf79e8c
Command Status Duration Result nx run tanstack-router-e2e-bundle-size:build --...✅ Succeeded 1m 28s View ↗
☁️ Nx Cloud last updated this comment at
2026-03-19 22:54:56UTCMore templates
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
- 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-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsc
- 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-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- 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-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- 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-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- 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-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
@tanstack/arktype-adapter
npm i https://pkg.pr.new/@tanstack/arktype-adapter@6645@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@6645@tanstack/history
npm i https://pkg.pr.new/@tanstack/history@6645@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@6645@tanstack/react-router
npm i https://pkg.pr.new/@tanstack/react-router@6645@tanstack/react-router-devtools
npm i https://pkg.pr.new/@tanstack/react-router-devtools@6645@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@6645@tanstack/react-start
npm i https://pkg.pr.new/@tanstack/react-start@6645@tanstack/react-start-client
npm i https://pkg.pr.new/@tanstack/react-start-client@6645@tanstack/react-start-server
npm i https://pkg.pr.new/@tanstack/react-start-server@6645@tanstack/router-cli
npm i https://pkg.pr.new/@tanstack/router-cli@6645@tanstack/router-core
npm i https://pkg.pr.new/@tanstack/router-core@6645@tanstack/router-devtools
npm i https://pkg.pr.new/@tanstack/router-devtools@6645@tanstack/router-devtools-core
npm i https://pkg.pr.new/@tanstack/router-devtools-core@6645@tanstack/router-generator
npm i https://pkg.pr.new/@tanstack/router-generator@6645@tanstack/router-plugin
npm i https://pkg.pr.new/@tanstack/router-plugin@6645@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@6645@tanstack/router-utils
npm i https://pkg.pr.new/@tanstack/router-utils@6645@tanstack/router-vite-plugin
npm i https://pkg.pr.new/@tanstack/router-vite-plugin@6645@tanstack/solid-router
npm i https://pkg.pr.new/@tanstack/solid-router@6645@tanstack/solid-router-devtools
npm i https://pkg.pr.new/@tanstack/solid-router-devtools@6645@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@6645@tanstack/solid-start
npm i https://pkg.pr.new/@tanstack/solid-start@6645@tanstack/solid-start-client
npm i https://pkg.pr.new/@tanstack/solid-start-client@6645@tanstack/solid-start-server
npm i https://pkg.pr.new/@tanstack/solid-start-server@6645@tanstack/start-client-core
npm i https://pkg.pr.new/@tanstack/start-client-core@6645@tanstack/start-fn-stubs
npm i https://pkg.pr.new/@tanstack/start-fn-stubs@6645@tanstack/start-plugin-core
npm i https://pkg.pr.new/@tanstack/start-plugin-core@6645@tanstack/start-server-core
npm i https://pkg.pr.new/@tanstack/start-server-core@6645@tanstack/start-static-server-functions
npm i https://pkg.pr.new/@tanstack/start-static-server-functions@6645@tanstack/start-storage-context
npm i https://pkg.pr.new/@tanstack/start-storage-context@6645@tanstack/valibot-adapter
npm i https://pkg.pr.new/@tanstack/valibot-adapter@6645@tanstack/virtual-file-routes
npm i https://pkg.pr.new/@tanstack/virtual-file-routes@6645@tanstack/vue-router
npm i https://pkg.pr.new/@tanstack/vue-router@6645@tanstack/vue-router-devtools
npm i https://pkg.pr.new/@tanstack/vue-router-devtools@6645@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@6645@tanstack/vue-start
npm i https://pkg.pr.new/@tanstack/vue-start@6645@tanstack/vue-start-client
npm i https://pkg.pr.new/@tanstack/vue-start-client@6645@tanstack/vue-start-server
npm i https://pkg.pr.new/@tanstack/vue-start-server@6645@tanstack/zod-adapter
npm i https://pkg.pr.new/@tanstack/zod-adapter@6645commit:
5ebfd2aWould be good to get this in, having to work around this error showing up in Sentry
zhuangya(GitHub profile, opens in a new tab) linked this to fix #6107
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
Adds handling for rejected lazy-route promises in loadRouteChunk: failed lazyFn now clears the route's _lazyPromise and prevents unhandled rejections, allowing retries. Successful lazy resolution behavior (merging lazy options, marking _lazyLoaded) is preserved.
Changes#
packages/router-core/src/load-matches.ts.catch()to the lazy-route promise chain to clearroute._lazyPromiseon rejection, gating component loading onroute._lazyLoadedand allowing retry after failure.packages/router-core/tests/load.test.ts_lazyPromise,_lazyLoadedflag behavior, and components loading state.Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers#
Poem#
🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
#6107by implementing a .catch() handler to prevent unhandled rejections from failed dynamic imports and allowing retry on subsequent navigation.main✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉
🧹 Recent nitpick comments
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