Skip to content

Errors thrown during hydrate not caught #5322

@roduyemi

Description

@roduyemi

Which project does this relate to?

Router

Describe the bug

If an error is thrown in the head function of a route, when the router hydrates, the exception is not caught and therefore the notFoundComponent is not rendered.

On the server, the notFoundComponent is rendered as expected.

Adding a catch here, results in the notFoundComponent being rendered.

May you please help look into this for us?

Thanks

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

  1. throw notFound() from a head function on a route
  2. Go to the url handled by the route
  3. Page crashes with:
{
    "data": {
        "data": {
            "isNotFound": true
        }
    },
    "__isServerError": true
}

Expected behavior

As a user, if I navigate to a page that doesn't exist, I can see a not found page, whether viewing on the server or client

Screenshots or Videos

No response

Platform

  • Router / Start Version: v1.132.27
  • OS: macOS
  • Browser: Chrome
  • Browser Version: Version 140.0.7339.208 (Official Build)
  • Bundler: vite
  • Bundler Version: 7.1.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