Commit b0474c81 authored by Balázs Orbán's avatar Balázs Orbán Committed by Jiachi Liu

fix(build-output): show stack during CSR bailout warning (#62594)

We should treat the warning for CSR bailout the same as the hard-error,
and show the stack trace for either case.

It might be useful to track down the source of this warning.

We have the stack info already, but we only showed it during the error
logging. We should show it for warnings too.

This is similar to #61200

Closes NEXT-2624
parent 1bee5b6c
...@@ -1006,10 +1006,8 @@ async function renderToHTMLOrFlightImpl( ...@@ -1006,10 +1006,8 @@ async function renderToHTMLOrFlightImpl(
// a suspense boundary. // a suspense boundary.
const shouldBailoutToCSR = isBailoutToCSRError(err) const shouldBailoutToCSR = isBailoutToCSRError(err)
if (shouldBailoutToCSR) { if (shouldBailoutToCSR) {
console.log()
if (renderOpts.experimental.missingSuspenseWithCSRBailout) {
const stack = getStackWithoutErrorMessage(err) const stack = getStackWithoutErrorMessage(err)
if (renderOpts.experimental.missingSuspenseWithCSRBailout) {
error( error(
`${err.reason} should be wrapped in a suspense boundary at page "${pagePath}". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout\n${stack}` `${err.reason} should be wrapped in a suspense boundary at page "${pagePath}". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout\n${stack}`
) )
...@@ -1018,7 +1016,7 @@ async function renderToHTMLOrFlightImpl( ...@@ -1018,7 +1016,7 @@ async function renderToHTMLOrFlightImpl(
} }
warn( warn(
`Entire page "${pagePath}" deopted into client-side rendering due to "${err.reason}". Read more: https://nextjs.org/docs/messages/deopted-into-client-rendering` `Entire page "${pagePath}" deopted into client-side rendering due to "${err.reason}". Read more: https://nextjs.org/docs/messages/deopted-into-client-rendering\n${stack}`
) )
} }
......
...@@ -39,6 +39,26 @@ createNextDescribe( ...@@ -39,6 +39,26 @@ createNextDescribe(
await next.renameFile('app/layout.js', 'app/layout-suspense.js') await next.renameFile('app/layout.js', 'app/layout-suspense.js')
await next.renameFile('app/layout-no-suspense.js', 'app/layout.js') await next.renameFile('app/layout-no-suspense.js', 'app/layout.js')
}) })
it('should pass build if missingSuspenseWithCSRBailout os set to false', async () => {
let _content
await next.patchFile('next.config.js', (content) => {
_content = content
return content.replace(
'{}',
'{ experimental: { missingSuspenseWithCSRBailout: false } }'
)
})
const result = await next.build()
expect(result.exitCode).toBe(0)
expect(result.cliOutput).toMatch(
'⚠ Entire page "/" deopted into client-side rendering due to "useSearchParams()". Read more: https://nextjs.org/docs/messages/deopted-into-client-rendering'
)
expect(result.cliOutput).toMatch(/app\/page\.js:\d+:\d+/)
await next.patchFile('next.config.js', _content)
})
}) })
describe('next/dynamic', () => { describe('next/dynamic', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment