test: cover SSR-logged Server Component errors with fake frames (#102470)
### What?
Adds an e2e test, `logged Server Component errors during ssr have
sourcemapped fake frames`, in `test/e2e/app-dir/server-source-maps`. A
Server Component creates an `Error` and passes it as a prop to a Client
Component. The Client Component then calls `console.error` on it during
SSR.
The test asserts that:
- the revived error's stack includes the replayed Server Component frame
(`at createServerError`). These frames come from React's fake functions,
which are named either after a virtual `about://React/...` URL or, since
#101522, after the server chunk;
- the logged stack and code frame are sourcemapped back to the Server
Component (`app/ssr-error-log-server-error/page.js`);
- no `about://React/` URL leaks into the CLI output.
### Why?
Existing tests cover SSR errors thrown in Client Components and errors
logged in RSC. They don't cover a Server Component error that is revived
during SSR, where the server frames in the stack are React's fake
frames.
How these frames get sourcemapped depends on Node's source-map settings.
Those settings are changing in upcoming Node.js versions:
nodejs/node#67627 skips source maps in `node_modules` by default. This
test should catch regressions there.
### How?
The fixture passes an `Error` across Flight. In dev, the Flight client
revives it inside React's fake call stack. The test checks Next's
terminal error inspection, which maps those frames through the server
chunk's source map. No source-map implementation changes.
### Verification
After rebasing onto canary `1010711b` (#101522), the new test was run on
its own with `-t "Server Component errors during ssr|SSR owner stacks"`,
once per bundler:
- `pnpm test-dev-turbo` and `pnpm test-dev-webpack` on Node 24: the new
test and #101522's `Server Component frames in SSR owner stacks are
sourcemapped` both pass.
- Negative control, with source maps disabled by a preload: the new test
fails on both bundlers on the mapped-stack assertion. The server-frames
marker stays `true`.
Before the rebase (canary `bd020231`), also once per configuration:
- `pnpm test-dev-turbo` and `pnpm test-dev-webpack` on Node 24: passes.
- The same, with Node's new default simulated by a `--require` preload
that calls `module.setSourceMapsSupport(true, { nodeModules: false,
generatedCode: true })`: passes.
- Negative control, with source maps disabled by a preload: fails on
both bundlers.
- Node `v28.0.0-nightly20261126fa49b1361b`, as part of the full
`server-source-maps` and `fake-frame-source-maps` suites: the new test
passes on both dev bundlers.
- This run needed a local workaround for an unrelated issue. On that
nightly `req.headers` has a null prototype, which breaks
`headers.hasOwnProperty` in
`packages/next/src/server/api-utils/index.ts`.
- The only other failure was in webpack dev: `handles invalid sourcemaps
gracefully` (missing `Invalid source map.` warning). It fails the same
way on Node 24 without any of these changes.
<!-- NEXT_JS_LLM -->
<!-- fleet fa924e06-041e-4299-abf0-5661b0a6019b -->
Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>