fix: preserve suspense promises for pending route matches #7051
main fromfix/pending-load-promise-suspense·opened Summary#
- keep a route's suspense promise alive while the match still renders as
pending - add a regular navigation regression test where aborting a pending route must keep rendering the pending UI
- add an
invalidate({ forcePending: true })regression test that keeps rendering the suspense fallback instead of throwingundefined
Testing#
CI=1 NX_DAEMON=false pnpm nx run @tanstack/react-router:test:unit --outputStyle=stream --skipRemoteCacheCI=1 NX_DAEMON=false pnpm nx run @tanstack/react-router:test:types --outputStyle=stream --skipRemoteCacheCI=1 NX_DAEMON=false pnpm nx run @tanstack/react-router:test:eslint --outputStyle=stream --skipRemoteCache
Summary by CodeRabbit#
Bug Fixes
- Prevented spurious error rendering during route loads and navigations; pending UI is now preserved when in-flight loaders are aborted or when reloads are forced into a pending state.
Tests
- Added regression tests covering aborted-loader navigation and forced-pending reloads to ensure pending UI remains visible and error components do not render incorrectly.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-router
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core
View your CI Pipeline Execution ↗ for commit 8e16dff9e260a3a0bbdc9fc4a719a1b82a80e0e9
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 15m 41s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 1m 45s View ↗
☁️ Nx Cloud last updated this comment at
2026-03-27 11:01:39UTC🚀 Changeset Version Preview#
2 package(s) bumped directly, 20 bumped as dependents.
🟩 Patch bumps#
Package Version Reason @tanstack/react-router1.168.7 → 1.168.8 Changeset @tanstack/router-core1.168.6 → 1.168.7 Changeset @tanstack/react-start1.167.12 → 1.167.13 Dependent @tanstack/react-start-client1.166.22 → 1.166.23 Dependent @tanstack/react-start-server1.166.22 → 1.166.23 Dependent @tanstack/router-cli1.166.22 → 1.166.23 Dependent @tanstack/router-generator1.166.21 → 1.166.22 Dependent @tanstack/router-plugin1.167.8 → 1.167.9 Dependent @tanstack/router-vite-plugin1.166.23 → 1.166.24 Dependent @tanstack/solid-router1.168.6 → 1.168.7 Dependent @tanstack/solid-start1.167.11 → 1.167.12 Dependent @tanstack/solid-start-client1.166.20 → 1.166.21 Dependent @tanstack/solid-start-server1.166.20 → 1.166.21 Dependent @tanstack/start-client-core1.167.6 → 1.167.7 Dependent @tanstack/start-plugin-core1.167.13 → 1.167.14 Dependent @tanstack/start-server-core1.167.6 → 1.167.7 Dependent @tanstack/start-static-server-functions1.166.22 → 1.166.23 Dependent @tanstack/start-storage-context1.166.20 → 1.166.21 Dependent @tanstack/vue-router1.168.6 → 1.168.7 Dependent @tanstack/vue-start1.167.11 → 1.167.12 Dependent @tanstack/vue-start-client1.166.20 → 1.166.21 Dependent @tanstack/vue-start-server1.166.20 → 1.166.21 Dependent Bundle Size Benchmarks#
- Commit:
21bd99242026 - Measured at:
2026-03-27T10:46:51.526Z - Baseline source:
history:42c3f3b3a3a4 - Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend react-router.minimal87.57 KiB +106 B (+0.12%) 276.01 KiB 76.09 KiB ██▇▇▃▃▂▂▂▂▁▂ react-router.full90.83 KiB +76 B (+0.08%) 287.20 KiB 79.02 KiB ██▇▇▃▃▂▂▂▂▁▂ solid-router.minimal35.58 KiB +72 B (+0.20%) 107.29 KiB 31.98 KiB ██▅▅▅▅▂▂▂▂▁▃ solid-router.full40.05 KiB +70 B (+0.17%) 120.82 KiB 36.02 KiB ██▄▄▄▄▃▃▃▃▁▃ vue-router.minimal53.44 KiB +78 B (+0.14%) 153.22 KiB 47.99 KiB ████▂▂▂▂▂▂▁▂ vue-router.full58.30 KiB +84 B (+0.14%) 168.68 KiB 52.30 KiB ████▃▃▂▂▂▂▁▂ react-start.minimal102.09 KiB +106 B (+0.10%) 324.19 KiB 88.32 KiB ██▆▆▂▂▂▂▂▂▁▂ react-start.full105.46 KiB +103 B (+0.10%) 334.55 KiB 91.11 KiB ██▇▇▂▂▂▂▂▂▁▂ solid-start.minimal49.68 KiB +80 B (+0.16%) 153.47 KiB 43.75 KiB ██▅▅▅▅▂▂▂▂▁▃ solid-start.full55.20 KiB +103 B (+0.18%) 169.71 KiB 48.53 KiB ██▄▄▄▄▃▃▃▃▁▄ Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.
- Commit:
More templates
- 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-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
- 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@7051@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7051@tanstack/history
npm i https://pkg.pr.new/@tanstack/history@7051@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7051@tanstack/react-router
npm i https://pkg.pr.new/@tanstack/react-router@7051@tanstack/react-router-devtools
npm i https://pkg.pr.new/@tanstack/react-router-devtools@7051@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7051@tanstack/react-start
npm i https://pkg.pr.new/@tanstack/react-start@7051@tanstack/react-start-client
npm i https://pkg.pr.new/@tanstack/react-start-client@7051@tanstack/react-start-server
npm i https://pkg.pr.new/@tanstack/react-start-server@7051@tanstack/router-cli
npm i https://pkg.pr.new/@tanstack/router-cli@7051@tanstack/router-core
npm i https://pkg.pr.new/@tanstack/router-core@7051@tanstack/router-devtools
npm i https://pkg.pr.new/@tanstack/router-devtools@7051@tanstack/router-devtools-core
npm i https://pkg.pr.new/@tanstack/router-devtools-core@7051@tanstack/router-generator
npm i https://pkg.pr.new/@tanstack/router-generator@7051@tanstack/router-plugin
npm i https://pkg.pr.new/@tanstack/router-plugin@7051@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7051@tanstack/router-utils
npm i https://pkg.pr.new/@tanstack/router-utils@7051@tanstack/router-vite-plugin
npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7051@tanstack/solid-router
npm i https://pkg.pr.new/@tanstack/solid-router@7051@tanstack/solid-router-devtools
npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7051@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7051@tanstack/solid-start
npm i https://pkg.pr.new/@tanstack/solid-start@7051@tanstack/solid-start-client
npm i https://pkg.pr.new/@tanstack/solid-start-client@7051@tanstack/solid-start-server
npm i https://pkg.pr.new/@tanstack/solid-start-server@7051@tanstack/start-client-core
npm i https://pkg.pr.new/@tanstack/start-client-core@7051@tanstack/start-fn-stubs
npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7051@tanstack/start-plugin-core
npm i https://pkg.pr.new/@tanstack/start-plugin-core@7051@tanstack/start-server-core
npm i https://pkg.pr.new/@tanstack/start-server-core@7051@tanstack/start-static-server-functions
npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7051@tanstack/start-storage-context
npm i https://pkg.pr.new/@tanstack/start-storage-context@7051@tanstack/valibot-adapter
npm i https://pkg.pr.new/@tanstack/valibot-adapter@7051@tanstack/virtual-file-routes
npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7051@tanstack/vue-router
npm i https://pkg.pr.new/@tanstack/vue-router@7051@tanstack/vue-router-devtools
npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7051@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7051@tanstack/vue-start
npm i https://pkg.pr.new/@tanstack/vue-start@7051@tanstack/vue-start-client
npm i https://pkg.pr.new/@tanstack/vue-start-client@7051@tanstack/vue-start-server
npm i https://pkg.pr.new/@tanstack/vue-start-server@7051@tanstack/zod-adapter
npm i https://pkg.pr.new/@tanstack/zod-adapter@7051commit:
8e16dffMerging this PR will not alter performance#
✅ 6untouched benchmarks
Comparingfix/pending-load-promise-suspense(8e16dff) withmain(42c3f3b)[^unexpected-base]- packages/router-core/src/load-matches.ts line 842OutdatedResolvedby Sheraff(GitHub profile, opens in a new tab)@@ -839,4 +839,4 @@839839 await runLoader(inner, matchPromises, matchId, index, route)840840 const match = inner.router.getMatch(matchId)!841841 match._nonReactive.loaderPromise?.resolve()842- match._nonReactive.loadPromise?.resolve()842+ if (match.status !== 'pending') {
why? is another resolve() problematic?
🧹 Nitpick comments (1)
packages/react-router/src/Match.tsx (1)
488-511: Unreachable server-side code in client-only component.Since
MatchInnerClientis only called when!(isServer ?? router.isServer)(see line 263), theisServercheck at line 494 will always be false. The server-side error rendering code (lines 495-507) is unreachable.♻️ Optional: Remove dead code
if (match.status === 'error') { - // If we're on the server, we need to use React's new and super - // wonky api for throwing errors from a server side render inside - // of a suspense boundary. This is the only way to get - // renderToPipeableStream to not hang indefinitely. - // We'll serialize the error and rethrow it on the client. - if (isServer ?? router.isServer) { - const RouteErrorComponent = - (route.options.errorComponent ?? - router.options.defaultErrorComponent) || - ErrorComponent - return ( - <RouteErrorComponent - error={match.error as any} - reset={undefined as any} - info={{ - componentStack: '', - }} - /> - ) - } - throw match.error }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react-router/src/Match.tsx` around lines 488 - 511, The server-side rendering branch inside the match.status === 'error' block is unreachable in MatchInnerClient because MatchInnerClient is only invoked when !(isServer ?? router.isServer); remove the dead server-specific code (the isServer ?? router.isServer check and the RouteErrorComponent JSX return) and leave the client behavior (throw match.error) or replace it with the appropriate client-only error handling; update the match.status === 'error' block in MatchInnerClient (referencing match, isServer, router.isServer, and RouteErrorComponent) to eliminate the unreachable server render path.🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Nitpick comments: In `@packages/react-router/src/Match.tsx`: - Around line 488-511: The server-side rendering branch inside the match.status === 'error' block is unreachable in MatchInnerClient because MatchInnerClient is only invoked when !(isServer ?? router.isServer); remove the dead server-specific code (the isServer ?? router.isServer check and the RouteErrorComponent JSX return) and leave the client behavior (throw match.error) or replace it with the appropriate client-only error handling; update the match.status === 'error' block in MatchInnerClient (referencing match, isServer, router.isServer, and RouteErrorComponent) to eliminate the unreachable server render path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
62dea7b3-5421-4bb4-adc3-2d8f241654e7📥 Commits
Reviewing files that changed from the base of the PR and between e1dbc02f99613567a1f8ae594004f22747bdd27f and 00ca45cf4c0d1351e122be2061ebb7b79683c719.
📒 Files selected for processing (2)
packages/react-router/src/Match.tsxpackages/router-core/src/load-matches.ts
💤 Files with no reviewable changes (1)
- packages/router-core/src/load-matches.ts
Sheraff(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
ae19c04d-88ae-42e0-b944-8e533fea4916📥 Commits
Reviewing files that changed from the base of the PR and between c07c593421d9bad1d9557842e6c1d38afa0aca52 and 8e16dff9e260a3a0bbdc9fc4a719a1b82a80e0e9.
📒 Files selected for processing (4)
packages/react-router/src/Match.tsxpackages/router-core/src/Matches.tspackages/router-core/src/load-matches.tspackages/router-core/src/router.ts💤 Files with no reviewable changes (1)
📝 Walkthrough
Walkthrough#
Preserves per-match pending render promises and avoids clearing
loadPromiseon resolved loaders for pending matches; adds tests covering loader aborts during navigation and forced-pending invalidation; introduces changeset.Changes#
packages/react-router/tests/loaders.test.tsx,packages/react-router/tests/router.test.tsxrouter.invalidate({ forcePending: true })keeps the pending UI during reload.packages/router-core/src/load-matches.tsmatch._nonReactive.loadPromisewhen loader resolution completes, preservingloadPromisefor pending matches.packages/router-core/src/Matches.ts_nonReactive.pendingRenderPromise?: ControlledPromise<void>toRouteMatchinternal state.packages/router-core/src/router.tsclearPendingRenderPromise(match?)and logic to clear or preserve per-matchpendingRenderPromiseduring mount, update, and invalidate flows.packages/react-router/src/Match.tsxmatch._nonReactive.pendingRenderPromise(creating it if missing/not pending) instead of throwing the match'sloadPromise..changeset/fancy-camels-rhyme.md@tanstack/react-routerand@tanstack/router-corewith a note about fixing undefined throws on immediate redirects.Sequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~45 minutes
Poem#
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (2 passed)
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.