3008af6b0e
### What Given user infomation when the dynamic errors are thrown, e.g. bad `cookies` or `headers` usages. Now users can tell through the error information to see which pathname is broken, and trace down the usage. #### before ``` Page couldn't be rendered statically because ... This page needs to bail out of prerendering at this point because ... ``` #### after ``` Route /cookies couldn't be rendered statically because ... Route /server needs to bail out of prerendering at this point because ... ``` ### Why When you have multi pages in your app, such as 100+, and many page might uses these. This is hard to trace down where exactly the error is from Closes NEXT-2283 Cloese NEXT-2265
20 lines
408 B
JavaScript
20 lines
408 B
JavaScript
import { Suspense } from 'react'
|
|
import { cookies } from 'next/headers'
|
|
|
|
export default async function Page() {
|
|
return (
|
|
<Suspense fallback={<div>Loading...</div>}>
|
|
<Foobar />
|
|
</Suspense>
|
|
)
|
|
}
|
|
|
|
async function Foobar() {
|
|
try {
|
|
cookies()
|
|
} catch (err) {
|
|
console.log('User land logged error: ' + err.message)
|
|
}
|
|
cookies() // still postpones so doesn't fail build
|
|
return null
|
|
}
|