-
Notifications
You must be signed in to change notification settings - Fork 28.4k
Custom error.tsx page is not rendered for dynamic routes using generateStaticParams / ISR in app router. Pages router 500.tsx is rendered instead #62046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I stumbled across this today, too, but for the 404 pages. // src/app/[[...slug]]/page.tsx
export function generateStaticParams() {
return ["home", "about", "career"].map((slug) => ({ slug: [slug] }));
}
export const dynamicParams = false;
export default function Page({ params }: any) {
const { slug } = params;
return <div>{slug}.</div>;
} // src/app/[[...slug]]/not-found.tsx
export default function NotFound() {
return <div>this page will never be rendered</div>;
} Accessing Repro: https://github.com/marlonschlosshauer/next-dynamic-routes-static-params-not-found |
Hi @marlonschlosshauer, I've managed to better identify the problem and I've found a workaround, although it's not the best one. What I've found out is that when I guess it could be the same for |
Hey @bkrajewski94 Thanks for the suggestion! Interestingly enough, that (thankfully?) didn't fix it for me. Running the app in dev mode also indicates that it is still using the global app directory 404 page:
Maybe we're having different issues after all. I work around for my issue would be to just use the default |
I've played around with it a bit by implementing my own error boundary. I think that the issue is caused by |
@marlonschlosshauer next.js/packages/next/src/build/index.ts Lines 923 to 926 in 160bb99
But it is You only can customize root directory 404 page for now. See doc. |
Having the same issue as well, with static routes and the app router. If I add a pages folder with 500.tsx, that error component is rendered instead. |
Having the same issues when running a Production build. Had to create a I don't know if that means that if you have an Funny enough when using the Hopefully they find a fix soon. |
+1 . Why don't internal errors jump to app/error.tsx? It seems that only errors thrown in server-side components will jump to app/error.tsx |
Seems like this is still broken in Next.js 15.0.4 (latest stable). Tested both locally in production build and on Vercel deploy:
It's been almost a year and new major version since this was first reported. |
I have the same issue as others. Interestingly, it works fine in Dev mode ( Any updates on possible workarounds? @leerob |
I can confirm this is still an issue in
Using the pages router to provide the custom error page is a workaround for aesthetic purposes. However it's not ideal to log errors from here, since server actions cannot be used directly from a client component in pages router. This would result in either leaking the api key for the logging service to the client, or provide an api route to log errors (which can easily be flooded by malicious users). It's been more than a year and in my opinion, this is really core functionality. Any updates or (better) workarounds? |
Link to the code that reproduces this issue
https://github.com/bkrajewski94/next-isr-error-page-bug
To Reproduce
npm install
npm run build
npm start
localhost:3000/test
Current vs. Expected behavior
If you use

generateStaticParams
inside a dynamic route like[slug]/page.tsx
, none of the customerror.tsx/global-error.tsx
pages will be displayed in case of an error. What you'll see instead is the NextJS inbuilt error pageIn the below example I used generateStaticParams to implement ISR (on request static generation):
It only breaks if you build your application (works fine on devserver).
As you can imagine it can be a big problem when you'd like to e.g. render a custom error page, or log error to an external system inside the error boundary.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 Binaries: Node: 20.10.0 npm: 10.2.3 Yarn: 1.22.21 pnpm: 7.1.0 Relevant Packages: next: 14.1.1-canary.52 // Latest available version is detected (14.1.1-canary.52). eslint-config-next: 14.1.0 react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local), Other (Deployed)
Additional context
No response
The text was updated successfully, but these errors were encountered: