TanStack / TanStack/router

Solid Router: root `errorComponent` never catches re-thrown errors when `shellComponent` renders `<Outlet />` directly

Open
#6,845 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

package: solid-router package: solid-start
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

When using shellComponent on the root route, if the shell function renders <Outlet /> directly (instead of {props.children}), the root's errorComponent never catches errors re-thrown from a child route's errorComponent.

This happens because shellComponent receives the CatchBoundary (which wraps errorComponent) as part of its children prop. When the shell ignores children and renders <Outlet /> directly — which is the natural and common pattern — the CatchBoundary is never placed in the render tree. Re-thrown errors from child errorComponent have no parent boundary to propagate to.

The same route structure works correctly in @tanstack/react-router because React uses the component pattern where CatchBoundary wraps the component (which contains <Outlet />), keeping it in the render tree.

Root route (__root.tsx) — Solid:

export const Route = createRootRoute({
  shellComponent: RootShell,
  errorComponent: ({ error }) => (
    <div data-testid="root-error">Root caught: {error.message}</div>
  ),
})

function RootShell() {
  return (
    <html>
      <head>...</head>
      <body>
        <Outlet />   {/* ← renders Outlet directly, bypasses CatchBoundary in children */}
        <Scripts />
      </body>
    </html>
  )
}

Child route (test-error.tsx) — identical for both Solid and React:

export const Route = createFileRoute('/test-error')({
  beforeLoad: () => { throw new Error('CHILD_THREW') },
  component: () => <div>never renders</div>,
  errorComponent: ({ error }) => {
    if (error.message === 'HANDLE_THIS') return <div>handled</div>
    throw error   // ← re-throw to parent
  },
})
Your Example Website or App

https://github.com/ljho01/tanstack-solid-router-error-mre

Steps to Reproduce the Bug or Issue
  1. cd solid && pnpm install && pnpm dev
  2. Open http://localhost:3001/
  3. Click "Go to /test-error (client nav)"
  4. Page goes blank — root errorComponent is never rendered

Compare with React:

  1. cd react && pnpm install && pnpm dev
  2. Open http://localhost:3002/
  3. Click "Go to /test-error (client nav)"
  4. Root errorComponent renders correctly with "Root errorComponent caught: CHILD_THREW"

E2E tests (optional):

# Solid — 2 of 3 FAIL
cd solid && pnpm install && npx playwright install chromium && pnpm test:e2e

# React — 3 of 3 PASS
cd react && pnpm install && npx playwright install chromium && pnpm test:e2e
Expected behavior

The root route's errorComponent should catch errors re-thrown from a child route's errorComponent, regardless of whether the shell renders <Outlet /> directly or uses {props.children}. This is consistent with how @tanstack/react-router behaves.

Screenshots or Videos

No response

Platform
  • Router / Start Version: @tanstack/solid-router 1.166.2, @tanstack/solid-start 1.166.2
  • OS: macOS 15.4
  • Browser: Chrome 135
  • Bundler: Vite 7.3.1
Additional context

Root cause in source (@tanstack/solid-router/dist/esm/Match.js):

In the Outlet component, when routeId() === rootRouteId, the child <Match> is rendered inside a <Suspense> but not inside a CatchBoundary. The root's CatchBoundary only exists as a child of ShellComponent (passed via props.children), so if the shell doesn't render its children, the boundary is absent.

A possible fix is to wrap the child <Match> inside the Outlet with the root's CatchBoundary when shellComponent is in use:

// In Outlet, when routeId() === rootRouteId:
const rootRoute = () => router.routesById[rootRouteId];
const needsRootCatchBoundary = () =>
  routeId() === rootRouteId && !!rootRoute().options.shellComponent;

// Wrap child match with CatchBoundary if shellComponent bypasses children
if (needsRootCatchBoundary() && rootErrorComponent()) {
  return createComponent(CatchBoundary, {
    getResetKey: () => resetKey(),
    errorComponent: rootErrorComponent(),
    onCatch: (error) => { /* ... */ },
    children: childMatch(),
  });
}

The repo includes a working patch in the linked reproduction.

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 by inspecting @tanstack/solid-router/dist/esm/Match.js, especially Outlet's root-route rendering and its CatchBoundary handling. Reproduce the failure with the Solid example, then run the Solid Playwright suite. Done means the root errorComponent catches a re-thrown child error when the shell renders directly, while the existing React and Solid cases still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.