Errors in generateMetadata are not being caught by the error.tsx file
Unanswered
Cape lion posted this in #help-forum
Cape lionOP
Hey guys, I'm using
It works in dev, but in prod it doesn't and I see the default Error 500 message from Nextjs.
This is my function:
Am I doing something wrong?
Nextjs 15.0.0-canary.104 and I noticed that if my generateMetadata() function results in an error, it's not being redirected as usual to the error.tsx I have set up at the root of my project.It works in dev, but in prod it doesn't and I see the default Error 500 message from Nextjs.
This is my function:
export async function generateMetadata({ params: { locale, publicId, slug }}: Props): Promise<Metadata> {
const t = await getTranslations({ locale })
const payload = await getPayloadHMR({
config: configPromise,
})
const data = await payload.find({
collection: 'jobs',
where: {
publicId: { equals: publicId },
slug: { equals: slug },
status: { equals: 'published' }
},
depth: 0,
})
if (!data.docs.length) {
return {
title: t('notFound'),
}
}
return {
title: t('seo.job.title', { title: data.docs[0].title }),
description: t('seo.job.description'),
}
}Am I doing something wrong?
4 Replies
Cape lionOP
I've also tried with [Handling Global Errors](https://nextjs.org/docs/app/building-your-application/routing/error-handling#handling-global-errors) and it doesn't catch it, not in dev nor in prod.
Cape lionOP
Anyone? 👀
Sounds like a framework bug
Cape lionOP
Thank you. That's a pretty big bug then, I'll submit a bug report later I guess. 
