Skip to content

Commit

Permalink
Add experimental flag for early exit on prerender error
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 22, 2024
1 parent aafb329 commit 5fb7a87
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,14 @@ export async function exportAppImpl(
})
})

if (nextConfig.experimental.prerenderEarlyExit) {
if (result && 'error' in result) {
throw new Error(
`Export encountered an error on ${path}, exiting due to prerenderEarlyExit: true being set`
)
}
}

if (progress) progress()

return { result, path }
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
parallelServerBuildTraces: z.boolean().optional(),
ppr: z.boolean().optional(),
taint: z.boolean().optional(),
prerenderEarlyExit: z.boolean().optional(),
proxyTimeout: z.number().gte(0).optional(),
serverComponentsExternalPackages: z.array(z.string()).optional(),
scrollRestoration: z.boolean().optional(),
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export interface NextJsWebpackConfig {
}

export interface ExperimentalConfig {
prerenderEarlyExit?: boolean
linkNoTouchStart?: boolean
caseSensitiveRoutes?: boolean
useDeploymentId?: boolean
Expand Down Expand Up @@ -837,6 +838,7 @@ export const defaultConfig: NextConfig = {
output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined,
modularizeImports: undefined,
experimental: {
prerenderEarlyExit: false,
serverMinification: true,
serverSourceMaps: false,
linkNoTouchStart: false,
Expand Down

0 comments on commit 5fb7a87

Please sign in to comment.