Skip to content

fix(router-core): load the ancestor errorComponent chunk that renders a child error - #8793

Open
sarankumar1325 wants to merge 1 commit into
TanStack:mainfrom
sarankumar1325:fix/load-ancestor-error-boundary-chunk
Open

sarankumar1325 wants to merge 1 commit into
TanStack:mainfrom
sarankumar1325:fix/load-ancestor-error-boundary-chunk

Conversation

@sarankumar1325

@sarankumar1325 sarankumar1325 commented Oct 23, 2026 •

Copy link
Copy Markdown

🎯 Changes

Fixes #8792.

When a child loader throws and the child has no errorComponent (and there is no defaultErrorComponent), the error renders through the nearest ancestor's errorComponent. reduceLane only loaded the failing match's own errorComponent chunk, so with a code-split ancestor boundary router.load() resolved before that chunk was ready and the first render was empty.

After loading the failing match's chunk, the lane now walks up to the first route whose errorComponent ?? defaultErrorComponent is set and loads that route's errorComponent chunk before committing. If the failing route (or the default) already provides one, nothing extra is loaded.

Tests in boundary-component-chunk.test.ts: load() stays pending until the ancestor's errorComponent preload resolves (fails on main), and the ancestor chunk is not requested when a defaultErrorComponent catches the error at the child.

Disclosure: written with AI assistance; I reviewed the change and ran the tests below.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

Tested: router-core test:unit (3653 passed), test:eslint, test:types; react-router, solid-router and vue-router test:unit pass.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • Child loader errors now wait for the nearest ancestor’s error screen to load before routing completes, so the correct error screen is available when the error is displayed.
    • When a child or router-level default error screen is configured, the ancestor error screen is not loaded unnecessarily.

@changeset-bot

changeset-bot Bot commented Oct 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f6c99d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@tanstack/router-core Patch
@tanstack/react-router Patch
@tanstack/react-start-client Patch
@tanstack/react-start-rsc Patch
@tanstack/react-start-server Patch
@tanstack/router-generator Patch
@tanstack/router-plugin Patch
@tanstack/solid-router Patch
@tanstack/solid-start-client Patch
@tanstack/solid-start-server Patch
@tanstack/start-client-core Patch
@tanstack/start-plugin-core Patch
@tanstack/start-server-core Patch
@tanstack/start-storage-context Patch
@tanstack/vue-router Patch
@tanstack/vue-start-client Patch
@tanstack/vue-start-server Patch
@tanstack/react-start Patch
@tanstack/router-cli Patch
@tanstack/router-vite-plugin Patch
@tanstack/solid-start Patch
@tanstack/start-static-server-functions Patch
@tanstack/vue-start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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 ⚠️ Failed 2026-10-23T03:38:54.191666Z
We couldn’t complete this review. Comment @codex review to try again.
f6c99d9 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.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 6b9fe6d and f6c99d9.

📒 Files selected for processing: 3
  • .changeset/ancestor-error-boundary-chunk.md
  • packages/router-core/src/load-client.ts
  • packages/router-core/tests/boundary-component-chunk.test.ts

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

📝 Walkthrough

When a child loader fails without a child or router default error component, the router loads the nearest ancestor’s error-component chunk before router.load() completes. Tests cover pending preloads and the router default case.

Changes: Ancestor error boundary loading

Layer / File(s) Summary
Load ancestor error boundary chunks
packages/router-core/src/load-client.ts, packages/router-core/tests/boundary-component-chunk.test.ts, .changeset/ancestor-error-boundary-chunk.md
Error handling loads the nearest ancestor’s error-component chunk when the failed route has no error component and the router has no default. Tests verify that router.load() waits for the preload and that a router default prevents the ancestor preload. The changeset declares a patch for @tanstack/router-core.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: sheraff

Merge Risk: ⚪ Minimal · up to f6c99

The ancestor error-boundary loading change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main fix: loading the ancestor errorComponent chunk for child errors.
Description check Passed The description explains the change, motivation, tests, AI assistance, release impact, and changeset. The checklist leaves the code-understanding item unchecked, but the author states that they review…
Linked Issues check Passed Issue #8792 requires router.load() to wait for the code-split ancestor errorComponent that renders a child loader error. reduceLane now loads the failing match chunk and then calls `loadAncestor…
Out of Scope Changes check Passed The changes stay within issue #8792. The source change implements ancestor boundary preloading. The tests cover the reported regression and the default-boundary case. The changeset documents the publi…
Full details: Description check

Explanation

The description explains the change, motivation, tests, AI assistance, release impact, and changeset. The checklist leaves the code-understanding item unchecked, but the author states that they reviewed the change, so the description is mostly complete.

Full details: Linked Issues check

Explanation

Issue #8792 requires router.load() to wait for the code-split ancestor errorComponent that renders a child loader error. reduceLane now loads the failing match chunk and then calls loadAncestorErrorComponent before the lane commits. The helper finds the nearest applicable ancestor and waits for its errorComponent preload. It skips the ancestor when the failed route or defaultErrorComponent already provides the boundary. The added tests cover both behaviors.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #8792. The source change implements ancestor boundary preloading. The tests cover the reported regression and the default-boundary case. The changeset documents the published behavior change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

router.load() resolves before an ancestor boundary's code-split errorComponent is loaded (regression in 1.170.19)

1 participant