Skip to content

Commit 13e06a3

Browse files
committed
avoid logging stacks for internal errors
1 parent 19e2edc commit 13e06a3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/next/src/export/worker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
import { needsExperimentalReact } from '../lib/needs-experimental-react'
4949
import { runWithCacheScope } from '../server/async-storage/cache-scope.external'
5050
import type { AppRouteRouteModule } from '../server/route-modules/app-route/module.compiled'
51+
import { isStaticGenBailoutError } from '../client/components/static-generation-bailout'
5152

5253
const envConfig = require('../shared/lib/runtime-config.external')
5354

@@ -440,9 +441,10 @@ export async function exportPages(
440441
}
441442
// If prerenderEarlyExit is enabled, we'll exit the build immediately.
442443
if (nextConfig.experimental.prerenderEarlyExit) {
443-
throw new ExportPageError(
444+
console.error(
444445
`Export encountered an error on ${pageKey}, exiting the build.`
445446
)
447+
process.exit(1)
446448
} else {
447449
// Otherwise, this is a no-op. The build will continue, and a summary of failed pages will be displayed at the end.
448450
}
@@ -540,7 +542,9 @@ async function exportPage(
540542
`\nError occurred prerendering page "${input.path}". Read more: https://nextjs.org/docs/messages/prerender-error\n`
541543
)
542544

543-
if (!isBailoutToCSRError(err)) {
545+
// bailoutToCSRError and staticGenBailoutError are errors that are thrown as flow control
546+
// rather than being useful errors to log.
547+
if (!isBailoutToCSRError(err) && !isStaticGenBailoutError(err)) {
544548
console.error(isError(err) && err.stack ? err.stack : err)
545549
}
546550

0 commit comments

Comments
 (0)