Skip to content

Issue with error boundary handling with throwing middleware #14145

@VillePakarinenPosti

Description

@VillePakarinenPosti

Reproduction

Following up on our discussion in #13766 (comment)

I've updated the reproduction to use v7.8.0 — you can check it out here:
👉 https://stackblitz.com/edit/github-ka7tf4zb-fqjd8nkf?file=app%2Froutes%2Findex.tsx

System Info

v7.8.0

Used Package Manager

npm

Expected Behavior

✅ Expected behavior :

  • When navigating to a route whose middleware throws and which exports an error boundary, the error should be caught and displayed by that route’s error boundary.

  • If no error boundary is defined on that route, the error should propagate up the route hierarchy and be caught by the nearest parent boundary. Such as a layout-level or root-level boundary.

  • This behavior should be consistent whether the navigation happens during initial render or after the app has loaded.

Actual Behavior

❌ Unexpected behavior with v7.8.0:

  • When navigating to a route with throwing middleware and an exported error boundary, the error is not caught by the route’s boundary.

  • Instead, the error bypasses all nested boundaries (including layout-level ones) and is caught by the root error boundary.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions