Next.js Discord

Discord Forum

SSG error.tsx not reached in production build

Unanswered
Somali posted this in #help-forum
Open in Discord
SomaliOP
Hello!

min example: https://github.com/ackoppel/next-ssg-error-page

We want to generate static pages after build time.
Following routing works for dev but fails in production builds.


page.tsx

export const dynamicParams = true;


export function generateStaticParams() {

  return [];

}


example dir tree:
/app
  /foo/[id]/page.tsx -> SSG
  /bar/[id]/page.tsx -> dynamic
  layout.tsx
  error.tsx


In production when SSG throws a runtime error, the error.tsx error boundary does not react and default nextjs 500 page is shown,

but..

When an error is thrown in a dynamic page, it will trigger the error.tsx as expected.

Issues I found but no good soulution yet:
https://github.com/vercel/next.js/issues/62046
https://github.com/vercel/next.js/issues/55462

Any one else? What work around have you found?

4 Replies

SomaliOP
Tried adding a ‘global-error.tsx’ but not luck.
Some posts suggest that adding an error page to ‘pages’ folder might help but this seems like an ugly work around
basically this behaviour truncates the whole layout : (
SomaliOP
If anyone is down to have a call on this, let me know
im afraid this is a nextjs bug so there isnt much that we can do except by following workarounds like you mentioned above, however dirty it may look like