Files
cloudflare__vinext/tests/fixtures/pages-basic/pages/error-throw.tsx
Divanshu Chauhan (divkix) ae0440b4f7 fix: support enablePrerenderSourceMaps config with default true (#973)
* fix: support enablePrerenderSourceMaps config with default true (#960)

Adds the `enablePrerenderSourceMaps` config option matching Next.js behavior.
Defaults to `true` so prerender stack traces resolve through sourcemaps to
original source files. Error results in prerender output now include full
stack traces when enabled. Node.js sourcemap support is enabled before the
prerender phase in both `cli.ts` (build) and `deploy.ts` (deploy).

Config parity: silently accepts the option; recognized as "supported" in
`vinext check` output.

* refactor: address review comments for enablePrerenderSourceMaps (#960)

- prerender.ts: simplify getErrorMessageWithStack and fix comment
  (V8's Error.stack always prepends message, remove startsWith guard)
- cli.ts: add Error.stackTraceLimit = 50 after setSourceMapsEnabled
- deploy.ts: add Error.stackTraceLimit = 50 after setSourceMapsEnabled
- next-config.test.ts: move enablePrerenderSourceMaps tests to own describe
  block and remove redundant explicit-true test

* fix(prerender): simplify getErrorMessageWithStack and add test coverage

Simplify the error stack handling in getErrorMessageWithStack by removing
the redundant nullish coalescing with empty string. The expression
`err.stack || err.message` handles all cases correctly.

Add test coverage proving that enablePrerenderSourceMaps: true (default)
includes stack traces in prerender errors. New test fixture page
`error-throw.tsx` throws during render to exercise the error path.

* fix(prerender): address review feedback - update snapshot, add config comment

- Regenerate entry-templates.test.ts.snap after adding error-throw fixture page
- Add comment clarifying enablePrerenderSourceMaps default in prerender test

* feat(config): add enablePrerenderSourceMaps config option

Adds support for the experimental.enablePrerenderSourceMaps config
option that Next.js 15+ introduced for debugging prerender issues.

Also includes merged changes from main:
- hashSalt: support experimental.outputHashSalt + NEXT_HASH_SALT env
- swcEnvOptions warning: warn about unsupported SWC polyfill option

All 75 next-config tests passing.

Closes #960
2026-05-01 22:41:12 +01:00

5 lines
207 B
TypeScript

// Page that throws an error during render — used to test enablePrerenderSourceMaps
export default function ErrorThrowPage() {
throw new Error("Intentional render error for prerender sourcemap test");
}