Gracefully handling "Prerender Errors" during dynamic route generation via generateStaticParams
Unanswered
Cynipid gall wasp posted this in #help-forum
Cynipid gall waspOP
Using the app router, I've got a dynamic route defined in
-
-
I'm generating a couple hundred routes initially in
However, occassionally one of those routes has an error on it, for one reason or another (e.g., some error gets thrown in the route due to bad data or something). This causes a "Prerender Error" on my route, and makes the build fail
(by prerender errors, I mean this which is thrown when a route fails to build: https://nextjs.org/docs/messages/prerender-error)
My question is: How can I gracefully handle an error on a single dynamic route being generated via
Simply showing a "404" on those problematic routes would suffice, but open to any other potential solutions.
app/[[...slug]]/page.tsx. This uses:-
export const dynamicParams = true-
export const generateStaticParams = ...I'm generating a couple hundred routes initially in
generateStaticParams, which is overall working well.However, occassionally one of those routes has an error on it, for one reason or another (e.g., some error gets thrown in the route due to bad data or something). This causes a "Prerender Error" on my route, and makes the build fail
(by prerender errors, I mean this which is thrown when a route fails to build: https://nextjs.org/docs/messages/prerender-error)
My question is: How can I gracefully handle an error on a single dynamic route being generated via
generateStaticParams so the entire build doesn't fail when that happens?Simply showing a "404" on those problematic routes would suffice, but open to any other potential solutions.
2 Replies
Cynipid gall waspOP
bump 🙂
Cynipid gall waspOP
bump