Skip to content

Attach the disallowed-dynamic reason to StaticGenBailoutError#95905

Open
yoshiki-maruya wants to merge 1 commit into
vercel:canaryfrom
yoshiki-maruya:fix/95867-static-gen-bailout-message
Open

Attach the disallowed-dynamic reason to StaticGenBailoutError#95905
yoshiki-maruya wants to merge 1 commit into
vercel:canaryfrom
yoshiki-maruya:fix/95867-static-gen-bailout-message

Conversation

@yoshiki-maruya

Copy link
Copy Markdown

What?

In 9 locations in packages/next/src/server/app-render/dynamic-rendering.ts and app-render.tsx (including throwIfDisallowedDynamic and throwIfSyncIOUsed), StaticGenBailoutError was being thrown without a reason; this has been changed so that the reason that was already logged via console.error right before the throw is now attached as the error's message (and, where the original error object exists, as the cause as well).

Why?

When runtime ISR revalidation failed, only an Error with an empty message was sent to error trackers via onRequestError, making the failure impossible to diagnose.

Side effects

The reason is now also displayed in the build output when a build fails (because the existing logic in the export worker prints StaticGenBailoutError messages when present). The ~130 updated snapshots under test/e2e/app-dir/cache-components-errors reflect this new output.

Testing

Added a new dynamic-rendering.test.ts (confirmed to fail without the fix). The cache-components-errors suite has been updated and passes in all modes (dev/start × Turbopack/Webpack × with and without debug-prerender).

Fixes #95867

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant