Skip to content
Source
Sign inSign up
TanStack/router

Errors thrown during hydrate not caught #5322

Send to my agent
Closedroduyemi(GitHub profile, opens in a new tab) opened this issue 7 comments

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

  1. want to create a PR for this?

    Hi @schiller-manuel, I'm happy to give this a go if you let me know what solution you're looking for. Thanks.

  2. you outlined a solution above, so why not give that a try? also add an e2e test for this please

  3. you outlined a solution above, so why not give that a try? also add an e2e test for this please

    I've added a PR for this here. Thanks

  4. @schiller-manuel may you or someone from the team please help me review this PR? Thanks

Sign in to join this conversation.