TanStack / TanStack/router

@tanstack/start issue - An error outside of the Outlet can't be caught and doesn't show error boundry

Open
#7,133 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

Which project does this relate to?

Start

Describe the bug

In my app I have a two providers which require a fetch from an API. During a release/startup the API might not have fully booted up yet causing this fetch to fail. The providers are defined in the _root.tsx before .

The result is that the server returns a JSON response:
{"status":500,"unhandled":true,"message":"HTTPError"}

I would have expected at least one error page to show (either from __root or the defaultErrorComponent from the router). No amount of error boundaries seem to help.

The biggest problem is that, because it can't be handled gracefully, the query can't be refetched and as such the server keeps throwing an error 500 even if the API has become available.

Your Example Website or App

https://github.com/Da-Teach/start-basic-react-query-error

Steps to Reproduce the Bug or Issue

The example git repo will immediately throw the error.

Expected behavior

I expect to see an error page but seeing a JSON error instead.

Screenshots or Videos

No response

Platform

Browser doesn't matter, nor platform.

"@tanstack/react-query": "^5.97.0",
"@tanstack/react-query-devtools": "^5.97.0",
"@tanstack/react-router": "^1.168.10",
"@tanstack/react-router-devtools": "^1.166.11",
"@tanstack/react-router-ssr-query": "^1.166.10",
"@tanstack/react-start": "^1.167.16",
"react": "^19.2.5",
"react-dom": "^19.2.5",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.1"

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked start-basic-react-query-error reproduction and inspect the providers in _root.tsx relative to . Reproduce the failed startup fetch, then trace TanStack Start's server error handling for errors thrown before the Outlet renders. Done means the failure shows an error page rather than the JSON 500 response and can be retried after the API becomes available.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
backend, full-stack
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.