mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
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
25 lines
419 B
TypeScript
25 lines
419 B
TypeScript
process.on('unhandledRejection', (rej) => {
|
|
console.log('unhandledRejection', rej)
|
|
process.exit(1)
|
|
})
|
|
|
|
export const revalidate = 0
|
|
|
|
export default function Layout({ children }) {
|
|
return (
|
|
<>
|
|
<p>Layout</p>
|
|
{children}
|
|
</>
|
|
)
|
|
}
|
|
|
|
export async function generateMetadata() {
|
|
await new Promise((resolve) => {
|
|
setTimeout(() => {
|
|
process.nextTick(resolve)
|
|
}, 2_000)
|
|
})
|
|
return {}
|
|
}
|