Files
JJ KasperandGitHub aa7ae420c6 Fix generateMetadata race condition (#63169)
This ensures we properly catch/handle `generateMetadata` errors during
eager evaluating of nested `generateMetadata` functions in the tree.
Previously if we eager evaluated a child metadata function that threw an
error e.g. `notFound()` and but the parent metadata function took longer
the thrown error would be an unhandled rejection causing the process to
crash depending on the environment.

Fixes: NEXT-2588


Closes NEXT-2786
2024-03-12 17:23:02 +00:00

18 lines
371 B
TypeScript

import type { ResolvingMetadata } from 'next'
import { notFound } from 'next/navigation'
process.on('unhandledRejection', (rej) => {
console.log('unhandledRejection', rej)
process.exit(1)
})
export const revalidate = 0
export default function Page() {
return notFound()
}
export async function generateMetadata(_, __: ResolvingMetadata) {
return notFound()
}