Skip to content

fix(react-router): catch falsy thrown values - #8205

Open
Sheraff wants to merge 1 commit into
mainfrom
fix/react-catch-boundary-falsy-values
Open

fix(react-router): catch falsy thrown values#8205
Sheraff wants to merge 1 commit into
mainfrom
fix/react-catch-boundary-falsy-values

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • preserve arbitrary falsy values caught by CatchBoundary using a truthy tuple state
  • keep the default error UI and development warning safe for nullish throws
  • cover all standard falsy values and the router default error UI

Bundle size

  • react-router.minimal: +9 gzip bytes, -3 raw bytes

Testing

  • CI will validate the isolated branch

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for routes that throw falsy or non-standard values.
    • Error components now receive the exact value that was thrown.
    • Default error screens display safely when no error message is available.
    • Warning logs now preserve the original error object for clearer diagnostics.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T19:27:51.593408Z a12302e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@nx-cloud

nx-cloud Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit a12302e

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

☁️ Nx Cloud last updated this comment at 2026-08-31 19:35:05 UTC

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b7f97737-e78a-4b9c-945f-870be8874ebf

📥 Commits

Reviewing files that changed from the base of the PR and between 37877da and a12302e.

📒 Files selected for processing (3)
  • packages/react-router/src/CatchBoundary.tsx
  • packages/react-router/src/Matches.tsx
  • packages/react-router/tests/errorComponent.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

CatchBoundary now preserves falsy thrown values, passes the original value to error components, and safely renders missing messages. Matches logs caught values directly. Tests cover falsy values, null, and undefined.

Changes

Falsy caught-value handling

Layer / File(s) Summary
Preserve and render caught values
packages/react-router/src/CatchBoundary.tsx
CatchBoundary stores caught values in a truthy tuple, resets with 0, passes the original value to errorComponent, and safely accesses its message.
Update reporting and validate falsy throws
packages/react-router/src/Matches.tsx, packages/react-router/tests/errorComponent.test.tsx
onCatch logs the error object directly. Tests verify exact falsy values and default error rendering for null and undefined.

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to a1230

This change preserves falsy thrown values while keeping the existing error UI and diagnostics safe. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, bundle impact, and testing plan, but it does not use the required "## 🎯 Changes" heading and omits the required checklist and release impact sections. Add the required "## 🎯 Changes", "## ✅ Checklist", and "## 🚀 Release Impact" sections. Complete each checklist item, state whether local tests were run, and indicate whether a changeset was generated or the change is docs/CI/dev-only.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing React Router handling for falsy thrown values.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/react-catch-boundary-falsy-values

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

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

4 package(s) bumped directly, 10 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.32 → 1.170.33 Changeset
@tanstack/solid-router 1.170.30 → 1.170.31 Changeset
@tanstack/start-plugin-core 1.171.39 → 1.171.40 Changeset
@tanstack/vue-router 1.170.29 → 1.170.30 Changeset
@tanstack/react-start 1.168.49 → 1.168.50 Dependent
@tanstack/react-start-client 1.168.30 → 1.168.31 Dependent
@tanstack/react-start-rsc 0.1.48 → 0.1.49 Dependent
@tanstack/react-start-server 1.167.37 → 1.167.38 Dependent
@tanstack/solid-start 1.168.47 → 1.168.48 Dependent
@tanstack/solid-start-client 1.168.29 → 1.168.30 Dependent
@tanstack/solid-start-server 1.167.36 → 1.167.37 Dependent
@tanstack/vue-start 1.168.46 → 1.168.47 Dependent
@tanstack/vue-start-client 1.167.32 → 1.167.33 Dependent
@tanstack/vue-start-server 1.167.36 → 1.167.37 Dependent

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a12302ed3d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}> {
state = { error: null } as { error: Error | null; resetKey?: unknown }
// Wrapping caught values keeps every possible thrown value truthy.
state = { error: 0 } as { error: [Error] | 0; resetKey?: unknown }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add a patch changeset for the published fix

This changes the runtime behavior of the published @tanstack/react-router package, but the commit contains no .changeset entry. CONTRIBUTING.md requires every published-package change to include one, so add a patch changeset to ensure this fix is represented in the release metadata and changelog.

AGENTS.md reference: AGENTS.md:L3-L5

Useful? React with 👍 / 👎.

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8205

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: a12302e

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 1e765c478bf0
  • Measured at: 2026-08-31T19:27:05.610Z
  • Baseline source: history:37877da166fe
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Initial (gzip) Raw Brotli Trend
react-router.minimal 83.8 KiB
+9 B
83.6 KiB
+8 B
262.2 KiB
-3 B
73.0 KiB
+86 B
▇▇██████▂▁▁▃
react-router.full 87.3 KiB
+4 B
87.2 KiB
+8 B
273.9 KiB
-3 B
76.1 KiB
+105 B
▇▇██████▁▁▁▂
react-start.minimal 96.7 KiB
+6 B
96.6 KiB
+3 B
304.4 KiB
-3 B
83.8 KiB
+153 B
▆▆██████▂▁▁▂
react-start.query-integration 104.0 KiB
+8 B
103.9 KiB
+6 B
330.9 KiB
-3 B
90.0 KiB
-169 B
▇██▁▁▁▃
react-start.deferred-hydration 97.4 KiB
+2 B
96.6 KiB
+2 B
305.8 KiB
-3 B
84.5 KiB
+46 B
▇▇██████▂▁▁▁
react-start.full 99.8 KiB
+7 B
99.7 KiB
+5 B
314.2 KiB
-3 B
86.4 KiB
-135 B
▇▇██████▂▁▁▂
react-start.rsbuild.minimal 100.0 KiB
+4 B
99.8 KiB
+4 B
314.8 KiB
-3 B
86.2 KiB
-39 B
▇▇██████▂▁▁▂
react-start.rsbuild.minimal-iife 100.4 KiB
+8 B
100.2 KiB
+8 B
315.7 KiB
-3 B
86.7 KiB
+175 B
▇▇██████▂▁▁▃
react-start.rsbuild.full 103.3 KiB
+8 B
103.1 KiB
+8 B
324.8 KiB
-3 B
89.0 KiB
-49 B
▇▇██████▃▃▁▃

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@codspeed-hq

codspeed-hq Bot commented Aug 31, 2026

Copy link
Copy Markdown

Merging this PR will regress 11 benchmarks

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 10 improved benchmarks
❌ 11 regressed benchmarks
✅ 159 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server serialization-payload (solid) 4.7 MB 7.4 MB -37.32%
Simulation client-control-flow navigation loop (react) 105.4 ms 114.6 ms -7.98%
Memory mem server error-paths unmatched (vue) 577.5 KB 627.2 KB -7.93%
Memory mem server server-fn-churn (solid) 336.7 KB 364.2 KB -7.57%
Memory mem server peak-large-page (vue) 1 MB 1.1 MB -6.99%
Memory mem server error-paths unmatched (react) 441.5 KB 464.8 KB -5.01%
Memory mem server aborted-requests (solid) 1.2 MB 1.2 MB -4.13%
Memory mem server peak-large-page (solid) 1.1 MB 1.2 MB -3.4%
Memory mem server request-churn (react) 639.3 KB 661.2 KB -3.32%
Memory mem server serialization-payload (vue) 4.4 MB 4.5 MB -3.08%
Memory mem client loader-data-retention (solid) 156.8 KB 161.7 KB -3.03%
Memory mem server error-paths redirect (vue) 891.9 KB 425.1 KB ×2.1
Memory mem server error-paths not-found (solid) 698.7 KB 540.9 KB +29.17%
Memory mem client preload-churn (vue) 919.3 KB 761.7 KB +20.7%
Memory mem server error-paths not-found (react) 436.4 KB 401.5 KB +8.69%
Simulation ssr global-mw document (solid) 366.2 ms 349.4 ms +4.8%
Memory mem client navigation-churn (solid) 649.4 KB 620 KB +4.74%
Memory mem client navigation-churn (vue) 1.7 MB 1.6 MB +4.74%
Memory mem server error-paths unmatched (solid) 570.7 KB 550 KB +3.76%
Memory mem server error-paths redirect (react) 315.9 KB 305.2 KB +3.51%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/react-catch-boundary-falsy-values (a12302e) with main (37877da)

Open in CodSpeed

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.

1 participant