Skip to content

fix(router): handle redirected lazy pending matches#7137

Merged
schiller-manuel merged 2 commits intomainfrom
fix-7120
Apr 10, 2026
Merged

fix(router): handle redirected lazy pending matches#7137
schiller-manuel merged 2 commits intomainfrom
fix-7120

Conversation

@schiller-manuel
Copy link
Copy Markdown
Contributor

@schiller-manuel schiller-manuel commented Apr 10, 2026

fixes #7120

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where redirected pending route transitions would cause render errors when the redirect target routes are lazy-loaded. The router now properly completes loading lazy-loaded routes after redirects are triggered during pending transitions.
  • Tests

    • Added test coverage for redirect scenarios with lazy-loaded route targets.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7a6ca3aa-4f0c-4cb4-af75-cb7bb3218be8

📥 Commits

Reviewing files that changed from the base of the PR and between f7e9c5e and 8730761.

📒 Files selected for processing (10)
  • .changeset/go-run-king.md
  • packages/react-router/src/Match.tsx
  • packages/react-router/tests/lazy/normal.tsx
  • packages/react-router/tests/redirect.test.tsx
  • packages/solid-router/src/Match.tsx
  • packages/solid-router/tests/lazy/normal.tsx
  • packages/solid-router/tests/redirect.test.tsx
  • packages/vue-router/src/Match.tsx
  • packages/vue-router/tests/lazy/normal.tsx
  • packages/vue-router/tests/redirect.test.tsx

📝 Walkthrough

Walkthrough

This PR fixes a regression where redirects thrown from a root route's beforeLoad with an active pendingComponent and pendingMs: 0 would fail. The fix involves suspending on the load promise for redirected matches instead of treating them as errors across React, Solid, and Vue routers, plus adds regression tests.

Changes

Cohort / File(s) Summary
Changeset
.changeset/go-run-king.md
Marks patch releases for React, Solid, and Vue routers with a fix for redirected pending route transitions.
React Router Core
packages/react-router/src/Match.tsx
Introduced getMatchPromise(match, key) helper to centralize promise retrieval. Updated all suspend sites to use this helper. Changed redirected branch to explicitly suspend on the match's load promise instead of treating as a warning case.
React Router Tests
packages/react-router/tests/lazy/normal.tsx, packages/react-router/tests/redirect.test.tsx
Added data-testid="lazy-route-page" to lazy route component. Added comprehensive regression test covering root beforeLoad redirect with pendingComponent and lazy target route loading.
Solid Router Core
packages/solid-router/src/Match.tsx
Added getLoadPromise(matchId, fallbackMatch) helper to retrieve load promises with fallback. Updated redirected branch to use this helper for promise resolution.
Solid Router Tests
packages/solid-router/tests/lazy/normal.tsx, packages/solid-router/tests/redirect.test.tsx
Added data-testid="lazy-route-page" to lazy route component. Added regression test for root beforeLoad redirect with pendingComponent and lazy target loading.
Vue Router Core
packages/vue-router/src/Match.tsx
Extended computed match object with _nonReactive field. Added getMatchPromise(match, key) helper with fallback logic. Updated redirected branch to use helper instead of direct promise access.
Vue Router Tests
packages/vue-router/tests/lazy/normal.tsx, packages/vue-router/tests/redirect.test.tsx
Added data-testid="lazy-route-page" to lazy route component. Added regression test for root beforeLoad redirect with pendingComponent and lazy target loading.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A hop, a skip, a promise thrown,
When redirects make their intentions known—
Now pending states suspend with grace,
No more errors in the wrong place! ✨
Lazy routes complete their gentle dance,
While routers redirect with perfect stance.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main fix: handling redirected lazy pending matches, which directly addresses the issue reported in #7120.
Linked Issues check ✅ Passed The PR successfully implements the fix for issue #7120 by modifying Match components across router packages to properly suspend on redirected matches during lazy-loaded route transitions, preventing the 'weird circumstance' error.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the redirected lazy pending matches issue: helper functions, promise handling updates, test cases validating the fix, and minor test markup additions for test selectors.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-7120

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

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Apr 10, 2026

View your CI Pipeline Execution ↗ for commit 4882d5e

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 6m 1s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 32s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-10 18:25:42 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

🚀 Changeset Version Preview

3 package(s) bumped directly, 9 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.168.10 → 1.168.11 Changeset
@tanstack/solid-router 1.168.9 → 1.168.10 Changeset
@tanstack/vue-router 1.168.9 → 1.168.10 Changeset
@tanstack/react-start 1.167.17 → 1.167.18 Dependent
@tanstack/react-start-client 1.166.26 → 1.166.27 Dependent
@tanstack/react-start-server 1.166.26 → 1.166.27 Dependent
@tanstack/solid-start 1.167.16 → 1.167.17 Dependent
@tanstack/solid-start-client 1.166.24 → 1.166.25 Dependent
@tanstack/solid-start-server 1.166.24 → 1.166.25 Dependent
@tanstack/vue-start 1.167.16 → 1.167.17 Dependent
@tanstack/vue-start-client 1.166.24 → 1.166.25 Dependent
@tanstack/vue-start-server 1.166.24 → 1.166.25 Dependent

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 10, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7137

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7137

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7137

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7137

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7137

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7137

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7137

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7137

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7137

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7137

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7137

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7137

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7137

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7137

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7137

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7137

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7137

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7137

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7137

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7137

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7137

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7137

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7137

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7137

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7137

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7137

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7137

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7137

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7137

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7137

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7137

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7137

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7137

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7137

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7137

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7137

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7137

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7137

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7137

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7137

commit: 4882d5e

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

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

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 10, 2026

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing fix-7120 (4882d5e) with main (f7e9c5e)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (1d31393) during the generation of this report, so f7e9c5e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@github-actions
Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 1d31393e3fd6
  • Measured at: 2026-04-10T18:19:39.880Z
  • Baseline source: history:f7e9c5e32379
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.50 KiB +18 B (+0.02%) 275.73 KiB 75.92 KiB ███▁▁▁▁▁▂▃▃▅
react-router.full 90.78 KiB +3 B (+0.00%) 286.91 KiB 78.83 KiB ▆▆█▁▁▁▁▁▂▂▂▃
solid-router.minimal 35.59 KiB +26 B (+0.07%) 107.33 KiB 31.99 KiB ▆▆▆▁▁▁▁▁▂▆▆█
solid-router.full 40.06 KiB +30 B (+0.07%) 120.86 KiB 35.91 KiB ▇▇▇▁▁▁▁▁▂▅▅█
vue-router.minimal 53.42 KiB +33 B (+0.06%) 153.13 KiB 48.03 KiB ███▁▁▁▁▁▂▄▄▇
vue-router.full 58.28 KiB +35 B (+0.06%) 168.60 KiB 52.22 KiB ███▁▁▁▁▁▂▄▄█
react-start.minimal 102.01 KiB +4 B (+0.00%) 323.97 KiB 88.19 KiB ▅▅█▁▂▂▂▂▃▃▃▄
react-start.full 105.40 KiB +23 B (+0.02%) 334.32 KiB 91.02 KiB ▆▆█▁▁▁▂▂▃▃▄▆
solid-start.minimal 49.69 KiB +28 B (+0.06%) 153.58 KiB 43.82 KiB ▅▅▅▁▁▁▂▂▂▆▆█
solid-start.full 55.20 KiB +26 B (+0.05%) 169.81 KiB 48.53 KiB ▆▆▆▁▁▁▁▁▂▆▆█

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

@schiller-manuel schiller-manuel merged commit b29d64d into main Apr 10, 2026
17 checks passed
@schiller-manuel schiller-manuel deleted the fix-7120 branch April 10, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'Tried to render a redirected route match! This is a weird circumstance, please file an issue!'

1 participant