Skip to content

errorComponent receives stale error from previous route after navigation #7121

@ali-idrizi

Description

@ali-idrizi

Which project does this relate to?

Router

Describe the bug

When navigating from a route that has an error (whether render or loader error) the destination route receives that error in errorComponent.

In minimal reproduction attached, I have three routes:

  • index (never throws)
  • render-error (always throws an error during render)
  • loader-error (always throws an error in loader).

The index route never throws, but despite that, its errorComponent receives the error of render-error or loader-error when navigating to it, as seen in this recording:

2026-04-08.14-39-35.mp4

Without looking at the logs the issue is not noticeable, as the index.errorComponent doesn't actually render. However, if errorComponent happens to throw (e.g. to let another error boundary handle it) then it will render a parents errorComponent, and the issue becomes apparent:

2026-04-08.14-38-22.mp4

Your Example Website or App

https://github.com/ali-idrizi/tanstack-router-error-boundary-leak

Steps to Reproduce the Bug or Issue

  1. Open the console
  2. Navigate to Render Error or Loader Error route
  3. Navigate back to Home
  4. Notice errorComponent console.error running despite the Home route never throwing an error

Expected behavior

The error from the previous route should not leak to an unrelated route

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.168.10
  • OS: Linux
  • Browser: Chrome
  • Browser Version: 146
  • Bundler: vite
  • Bundler Version: 7.3.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions