Skip to content

fix(docs): guard against undefined loaderData during route transitions - #1508

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix-docs-loader-destructure-crash
Open

sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix-docs-loader-destructure-crash

Conversation

@sentry

@sentry sentry Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

In both /_library/$libraryId/$version/docs/framework/$framework/$ and /_library/$libraryId/$version/docs/$, the Docs component immediately destructured properties such as { content, filePath, title, freshness, canonicalPathOverride } from Route.useLoaderData().

During certain client-side navigation transitions, TanStack Router can briefly render a route match before its loader data has arrived, resulting in Route.useLoaderData() returning undefined and throwing an unhandled TypeError: Cannot destructure property 'content' from null or undefined value.

Changes made:

  • Guard against undefined loaderData in both docs routes, returning a placeholder DocContainer until loader data is populated.
  • Record occurrences via Sentry.captureMessage at the warning level so router data races remain visible and traceable without crashing the page.
  • Run oxlint and format the modified files.

Fixes TANSTACK-COM-419

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: feca5af3-f5df-4d67-9875-c78c7fbbbcfa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

@changeset-bot

changeset-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 440ffbe

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 440ffbe Commit Preview URL

Branch Preview URL
Nov 17 2026, 11:18 PM

@tannerlinsley

Copy link
Copy Markdown
Member

Thanks for catching this. Can we pin down the navigation that loses the loader data and show that the docs recover? An empty container avoids the destructuring error, but we need to know it does not leave the page blank.

AI review notes:
Reviewed the three-file diff at 440ffbea709f6d2abf8dac217ea7c4f0e2018b33. Both routes now return an empty DocContainer when loader data is missing. The diff has no regression test demonstrating that the router subsequently supplies the data and renders the document. I have not reproduced the reported transition.
Please add a regression covering the triggering navigation, including the eventual document content and failure behavior, and trace why a matched route renders without its loader result. The two as ReturnType<typeof Route.useLoaderData> | undefined assertions also conflict with this repository's no-casts rule, fix the typing at its source instead.

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.

1 participant