Errors thrown during hydrate not caught #5322
Send to my agentWhich 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#
- throw
notFound()from aheadfunction on a route - Go to the url handled by the route
- 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
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.
you outlined a solution above, so why not give that a try? also add an e2e test for this please
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
@schiller-manuel may you or someone from the team please help me review this PR? Thanks
See https://github.com/TanStack/router/pull/5686 for the latest PR to resolve this
confirmed to be fixed
birkskyum(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
want to create a PR for this?