new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Next.js App Router · all subjects

building & deployment

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

SWC plugin transforms Error instances to include __NEXT_ERROR_CODE property

The Next.js error code SWC plugin rewrites `new Error` or `Error` to attach a `__NEXT_ERROR_CODE` property using `Object.defineProperty(new Error(...), "__NEXT_ERROR_CODE", { value: $code, enumerable: false, configurable: true })`. The `enumerable: false` setting prevents the error code from appearing in console logs while keeping it accessible for telemetry. The `configurable: true` setting allows the error code to be overwritten when transforming errors.

Error code mapping stored in packages/next/errors.json

Next.js maintains an append-only, increment-based mapping of error codes to messages in the file `packages/next/errors.json`.

pnpm build automatically updates errors.json with new error codes

Running `pnpm build` automatically updates `packages/next/errors.json` if new errors are introduced. The updated `errors.json` file must be committed to avoid CI failures.

Two-pass build process for error code extraction

Next.js uses a two-pass build system for error code mapping. In the first pass, new errors are extracted and temporarily stored in `packages/next/.errors/*.json`; if new errors are found during CI, the build fails. In the second pass, `packages/next/errors.json` is updated and the build step is rerun to confirm no further new errors are introduced. This system ensures reliable ordering of inserted error codes during concurrent builds, following React's error mapping mechanism.

Rebuild WASM after modifying error code SWC plugin

After modifying the error code SWC plugin, rebuild the WASM file by running `pnpm build-error-code-plugin` and commit it to the repository. Pre-built artifacts are necessary to simplify the build process, as `pnpm build` runs without requiring `cargo` installation.

Test error code SWC plugin with cargo test

To test the error code SWC plugin, run `cargo test` inside the `crates/next-error-code-swc-plugin` directory.

Error code reporting enables anonymous feedback with private messages

The error code transformation enables anonymous error code reporting for user feedback while keeping the error message private.

Give your agent this brain

building & deployment — Next.js App Router