Skip to content

No app/global-error.tsx, so a root layout crash falls back to the default Next.js error page #62

Description

@royalpinto007

The app has app/error.tsx and app/not-found.tsx, but no app/global-error.tsx.

error.tsx only catches errors thrown inside the layout it sits under. An error thrown in the root layout itself, or in the root error boundary, is not caught by it. Next.js falls back to its built-in error page, which is unstyled, unbranded, and in production says nothing more useful than that something went wrong.

For a site people are arriving at from shared links, that is the worst possible first impression, and we would not see it in local development because the dev overlay hides it.

Suggested fix

Add app/global-error.tsx. It must render its own <html> and <body>, since it replaces the root layout. Keep it dependency-free and inline-styled, because whatever broke may be the thing that would have loaded the styles.

Give it a link back to the home page and a way to report the case.

Acceptance

  • app/global-error.tsx exists and renders its own html and body
  • It does not import from the component library or anything that could itself fail
  • Verified by temporarily throwing in the root layout

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions