Commit Graph

28 Commits

Author SHA1 Message Date
Hendrik Liebau dae438dc0d Stop printing a stack frame for error message text (#97829)
Next.js printed a stack frame that does not exist for an error whose
message ends with text that looks like a file location. A logged
connection failure read `at <unknown> (Error: connect ECONNREFUSED
::1:45999)` in front of its real frames.

`stacktrace-parser` tries five patterns on every line, and the pattern
for JavaScriptCore makes the `<name>@` prefix optional. That pattern
`:<line>:<column>`, and a line of an error message can end that way. A
JavaScriptCore frame always holds `@`, also at the top level, so the
prefix is not optional in a real stack.

The patch for `stacktrace-parser` now requires that prefix. A line of a
message no longer becomes a frame, and every JavaScriptCore frame still
parses, including one whose path holds a space.

A Turbopack build error puts the file and the position of the error in
its message, and the parser read that line as a frame as well. That
frame is gone now, and the location stays in the message. The snapshots
of the build errors record the change.
2026-08-25 13:38:47 +02:00
Hendrik Liebau bf07db0713 Show the errors of an AggregateError behind a cause (#97830)
A failed `fetch` hid the reason of the failure. Node.js reports every
refused connection attempt in the `errors` of an `AggregateError`, and
the terminal logged `[errors]: [ [Error], [Error] ]` without the address
or the port of a single attempt.

An `AggregateError` keeps its errors in an array. Node.js spends one
level of the inspect depth on that array, and one more level on each
error in the array, while a `cause` costs one level only. The errors of
an `AggregateError` behind a cause therefore fell outside the default
depth of two. Node.js also returns an error early when it carries no own
properties, before it applies the depth, so the collapse hit only the
errors that carry diagnostics.

Next.js now adds the missing level back for an `AggregateError`, so its
errors print at the same nesting as a cause. A depth of `null` means
unlimited and stays unchanged, because `null + 1` would reduce it to one
level.
2026-08-25 10:07:55 +02:00
dan 2549514abd [test] Add source-mapping coverage of React's fake stack frame scripts in use cache (#95945)
Adds tests verifying that`use cache` stacks get symbolicated.

We noticed insufficient coverage in
https://github.com/vercel/next.js/pull/95936, which should have failed
the tests (it broke symbolication) but tests passed. So this restores
the missing stack assertions. This also adds some new coverage that
specifically verifies that symbolicating via CDP also works.
2026-07-22 11:52:11 +01:00
Aurora Scharff a0c6a6140e instant: enable navigation validation by default (#94312)
### What?

Flips the default `experimental.instantInsights.validationLevel` from
`'manual-warning'` to `'warning'` so Cache Components apps get
instant-navigation validation across all pages by default.

### Why?

`'manual-warning'` only validates pages that explicitly export
`unstable_instant`, so apps see nothing unless they opt in. `'warning'`
is what users have been turning on manually to actually see the feature
(`v0`, `vercel-site`).

### Test coverage

- Unit: `instant-config-normalization.test.ts` pins the framework
default at `'warning'`.
- Integration: new `instant-validation-level-default/` fixture (no
`instantInsights` in config) asserts implicit dev validation fires, and
that build is unaffected.

### Collateral test fixtures

Tests whose intent is unrelated to instant validation
(router-autoscroll, owner-stack, hmr-iframe, next-image,
server-source-maps, etc.) now hit new redboxes/console warnings because
their fixtures incidentally use dynamic data. Each opts out with
`experimental: { instantInsights: { validationLevel: 'manual-warning' }
}` in `next.config`.

### Open question

With no `'off'` / `'info'` tier today, silencing Insights after this
change requires setting `validationLevel: 'manual-warning'`. Is that
acceptable? Should we inform of this anywhere?

<!-- NEXT_JS_LLM_PR -->
2026-06-03 01:26:11 +02:00
Hendrik Liebau 2544783173 Skip dimming when --inspect is used (#91271)
When the Node.js inspector is active (e.g. via `next dev --inspect`),
dimming wraps console arguments in a format string which defeats
inspector affordances such as collapsible objects and
clickable/linkified stack traces.

This adds an early return in `convertToDimmedArgs` that skips dimming
entirely when `inspector.url()` is defined. Terminal output without
`--inspect` is unchanged.

Ideally we would only skip dimming when a debugger frontend is actually
attached, but Node.js does not expose a synchronous API for that —
detecting it would require async polling of the `/json/list` HTTP
endpoint.

Test plan:
- Unit tests in `console-dim.external.test.ts`
- Manual: dimming almost never triggers now since we switched to in-band
validation (no separate render pass). To reproduce manually, use a
client component that calls `console.error(new Error(...))` during SSR,
e.g.:
1. `__NEXT_CACHE_COMPONENTS=true pnpm next dev
test/e2e/app-dir/server-source-maps/fixtures/default --inspect`
  2. Open `http://localhost:3000/` in Chrome
  3. Click the Node.js DevTools button
  4. Load `http://localhost:3000/ssr-error-log`
5. Verify the first error in DevTools has source-mapped, expandable
stack frames

Before:

<img width="1496" height="848" alt="before"
src="https://github.com/user-attachments/assets/8b4358e1-06ec-4078-b6cc-269986e295e7"
/>

After:

<img width="1496" height="842" alt="after"
src="https://github.com/user-attachments/assets/42f33c6f-f025-410f-b44c-2ccd88fe0cfe"
/>
2026-03-13 16:17:43 +01:00
Ben Brook a4f8b179e1 Include AggregateError.errors in terminal output (#88999)
Co-authored-by: bencmbrook <7354176+bencmbrook@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-02-09 00:18:03 +01:00
Sebastian "Sebbie" Silbermann a91b3609d0 Ensure Errors with deep causal chains respect inspect depth (#89594)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: bencmbrook <7354176+bencmbrook@users.noreply.github.com>
2026-02-06 14:02:05 +01:00
Zack Tanner 85c3d20a91 [cache components]: move flag out of experimental (#85035)
This moves `experimental.cacheComponents` to a top level config. As part
of this, I disabled some tests in `build-output-prerender` that assert
on `cacheComponents` appearing in the experimental list. In a separate
PR, I'm going to show that Cache Components is enabled next to the
bundler info.

This also updates some docs pages to remove "experimental" language.
2025-10-18 14:13:44 -07:00
Wyatt Johnson 8abbb3dc2e refactor: rename experimental.dynamicIO to experimental.cacheComponents (#81562)
## What?

Rename `experimental.dynamicIO` to `experimental.cacheComponents` across
the Next.js codebase.

## Why?

We're going to be merging the functionality of the `ppr`, `dynamicIO`
and `useCache` experimental flags into the singular `cacheComponents`
flag to reduce complexity of the codebase and simplify adoption for
users wanting to experiment with experimental features.

## How?

- Renamed the configuration option from `experimental.dynamicIO` to
`experimental.cacheComponents`
- Added deprecation handling with automatic migration for the old option
name
- Updated all documentation, tests, and internal references
- Updated Rust code in SWC transforms and Turbopack
- Maintained backward compatibility with deprecation warnings

NAR-158
2025-07-17 19:30:28 -06:00
Sebastian "Sebbie" Silbermann 4618e3d902 Hide <anonymous> stackframes if sandwiched between two ignore-listed frames (#81067) 2025-07-14 11:41:04 +02:00
Sebastian "Sebbie" Silbermann 11cbba8bd5 [build-sourcemaps] Default experimental.enablePrerenderSourceMaps to experimental.dynamicIO (#81449) 2025-07-09 15:11:24 +02:00
Sebastian "Sebbie" Silbermann a0a882e063 Current behavior for module evaluation sourcemapping (#73737)
Looks pretty bad. Most of it is due to added functions by bundlers that aren't sourcemapped.
2025-07-04 18:21:10 +02:00
Sebastian "Sebbie" Silbermann 854992f4d7 [build-sourcemaps] Sourcemap errors during prerender if experimental.enablePrerenderSourceMaps is enabled (#79109) 2025-05-19 19:16:34 +02:00
Hendrik Liebau 2a95766744 Remove obsolete ppr configs from Dynamic IO tests (#79305)
Now that `ppr` is enabled by default when `dynamicIO` is enabled, we can remove the obsolete `ppr: true` configs from the Dynamic IO tests.
2025-05-19 16:52:03 +02:00
Sebastian "Sebbie" Silbermann 34039551d2 [test] Use unique error messages in server-source-maps (#79108)
Allows unambigious assertions on CLI output.
Not that interesting for dev but `next build` will have the logs for all pages in all tests.

I also made the pages static where possible so that we'll be able to assert on the logged errors during `next build`.
2025-05-19 08:38:59 +02:00
Hendrik Liebau 53933954e3 Enable PPR in Dynamic IO tests (#79301)
To prepare for an upcoming change where `ppr` will be enabled
automatically when `dynamicIO` is enabled, we're hard coding `ppr: true`
in the Dynamic IO tests with this PR. The non-PPR assertions are
subsequently removed, which makes up most of the changed lines.

We can now also exclude the tests in the PPR tests manifest, so that
they're not run twice in CI.

> [!NOTE]  
> This PR is best reviewed with hidden whitespace changes.
2025-05-17 20:50:29 +02:00
Sebastian "Sebbie" Silbermann 5b3ba20cca [build-sourcemaps] Allow inspecting prerender worker (#79098)
If `--inspect` or `--inspect-brk` is specified, prerender will no longer time out since that's most likely not wanted (e.g. you'd always get timeouts if you set breakpoints).

Inspecting prerender workers is best done with `experimental.cpus: 1`.
Only the first prerender worker can be inspected since we can't set `NODE_OPTIONS` based off of the worker index.

This PR also sets up infra for inspecting arbitrary workers. Their debug port would need to be coordinated within `getNextBuildDebuggerPortOffset`. This doesn't work if worker creation is shared between `next build` and `next dev` which I haven't checked if that's the case.
2025-05-13 19:03:26 +02:00
Sebastian "Sebbie" Silbermann 00e2e0ab13 [test] Repro for dropped ignoreList by Turbopack in browser sourcemaps (#78822) 2025-05-05 14:29:50 +00:00
Sebastian "Sebbie" Silbermann 124a7a7bc1 [dev-overlay] Only warn once per invalid sourcemap (#77444) 2025-04-02 18:22:01 +02:00
Sebastian "Sebbie" Silbermann dcffe81617 Create valid URLs in source map sources with Turbopack (#76075) 2025-02-15 22:37:43 +01:00
Sebastian "Sebbie" Silbermann a71a764cae Add test for missing sourcemap loader support of ignoreList (#75907)
Neither Webpack nor Turbopack preserve this property. Webpack is even worse because the original source URLs are malformed.
2025-02-12 09:13:22 +01:00
Sebastian "Sebbie" Silbermann c0031816f3 Handle invalid sourcemaps (#75713) 2025-02-09 13:40:10 +01:00
Sebastian "Sebbie" Silbermann 4c7ef6a727 Ignore-list stack frames in node_modules even if not explicitly ignore-listed by their sourcemaps (#73689) 2024-12-09 18:18:12 +01:00
Sebastian "Sebbie" Silbermann 2ce4e440bd Expand server-source-maps scenarios to cover Edge runtime (#72288)
...and use test patterns more consistently
2024-11-09 14:19:08 +01:00
Sebastian "Sebbie" Silbermann 655b808c5b Run with --enable-source-maps by default in next dev (#71820)
We already create server source maps in dev by default,
so we should make use of them.

To opt-out, run `next dev --disable-source-maps` instead.

Our internal `next-no-sourcemaps` script is now defunct.
2024-10-28 10:23:03 +01:00
Sebastian "Sebbie" Silbermann 596382b7f7 Reland "Sourcemap errors in terminal by default" (#71877) 2024-10-25 22:58:23 +02:00
Sebastian "Sebbie" Silbermann bf5ffaf2c4 Revert "Sourcemap errors in terminal by default (#71444)" (#71868) 2024-10-25 20:51:38 +02:00
Sebastian "Sebbie" Silbermann af6f6aa96c Sourcemap errors in terminal by default (#71444) 2024-10-24 15:11:10 +02:00