Commit Graph
868 Commits
Author SHA1 Message Date
Jiachi LiuandGitHub 27250721aa [segment explorer] redesign file pills and boundary trigger (#81302) 2025-07-11 15:42:57 +02:00
Sebastian "Sebbie" SilbermannandGitHub 16c53236a7 Configure url for responses from patched fetch like the original response.url (#81507)
The main config that was missing is enumerability which is relevant for showing properties in the Chrome performance track and inferring shorthands.
2025-07-11 00:05:27 +02:00
Sebastian "Sebbie" SilbermannandGitHub df2c2a8cf0 [sourcemaps] Stop sending stackframes in third-party chunks (#81344) 2025-07-10 23:29:58 +02:00
Hendrik LiebauandGitHub b5ced37273 Name patched fetch function fetch (#81499)
This ensures that `fetch` is shown in stack traces (in collapsed
ignore-listed frames), instead of `patched`.
2025-07-10 15:48:42 +02:00
Rob PruzanandGitHub 94f8aecf26 feat: forward browser errors/logs to terminal (#80909)
Closes NEXT-4534

This PR introduces the ability for next.js to forward logs, errors, and
unhandled rejections from the browser to the terminal the dev server is
running in (behind an experimental flag)

# Explanation

The 2 main components of this pr are the client side error accumulation
logic, and the ingest handling on the other side of the hmr socket.

We listen on the existing hmr socket to send batched logs, errors, and
uncaught rejections the frame after they were captured. All forwarded
data is sent with metadata so we can have reconstruct the log with an
equivalent level of information to the browser- since we expect AI
agents that can't access the browsers to be consumers of this feature
(and it's generally useful).

All foreign data created by the user in the browser is serialized using
`safe-stable-serializer`, a popular serializer [used by other logging
libraries](https://www.npmjs.com/browse/depended/safe-stable-stringify),
like
[pino](https://github.com/search?q=repo%3Apinojs%2Fpino+safe-stable&type=code)
(safety, determinism, fast). We also have a light shim on top of json
serialization to handle displaying custom data representations that
either wouldn't survive serialization (undefined) or we want to present
to users in a custom format (throwing proxies, promises, ...)

On the dev server server, we (bespoke) deserialize, source map, format,
and log. I tried to share as much logic as I could with error dev
overlay to avoid feature drift since they are very similar
implementations other than the render target


# Explicitly covered cases

- console table
  - shows as `[browser]\n<table>\n(<source location>)`
- console trace
- shows as `[browser] arg1 arg2 ...\n<stack trace>\n([source mapped
location of log]`)`
  - trace is source mapped
- ignored frames are shown, incase people explicitly want the full trace
- console dir
  - shows as `[browser] arg1 arg2 ([source mapped location of log])`
- we need to explicitly capture stdout and rewrite it when we call nodes
`console.dir` to prefix and postfix with [browser] and and (`<source
mapped location of log>`) without adding newlines (we could do this for
console.table but it makes sense to keep the prefix and postfix on new
lines)

- console error
- `[browser] arg1 arg2 \n codeblock + source mapped stack of
console.error ([source mapped location of console.error])`
- if there are any `Error` values present we wont show the stack and
code block of console.error since it's overwhelming (this is fine since
we still tell the user where the `console.error` is with the appended
location)
- rejected promises that have `Error`'s
- behave identical to console.error, but is prepended with `⨯
unhandledRejection`
	- the `Error`'s render with their source mapped stack + ignored frames
- no error stack can be automatically appended where the promise
rejected
- rejected promises that have non `Error` values
- prepended with `⨯ unhandledRejection: ${error.name}: ${error.message}`
	- everything is logged in red
- no error stack can be automatically appended where the promise
rejected
- on caught error
	- prepended with `Uncaught ${errorName}: ${errorMessage}`
- stack attached to error is source mapped + ignored frames are not
shown
- everything is logged in red but the code block of where the error
orginated from
- all other console cases
  - shows as `[browser] arg1 arg2 ([source mapped location of log])`
- if an error is passed, we show the error name, message, source mapped
stack (colored white, ignored frames not shown), and code block if
available (syntax highlighted)
  - we apply util.format to handle formatted strings
- logs captured during RSC rendering
  - not piped to server, ignored on client


Closes NEXT-4534
2025-07-08 19:40:01 -04:00
Jiachi LiuandGitHub 2503c19dd0 [segment explorer] capture defined boundaries (#81232)
Capture defined boundaries (not-found / error / loading) and used to filter which one is available for boundary triggers

The trie will now hold all the defined boundaries, but what's different from the existing rendered boundaries is:

Here's the difference of new defined boundary trie nodes:
```
{
  type: "boundary:<type>"
  pagePath: "<pagePath>@boundary"
}
```
We add a `boundary:` prefix to determine if it's node representing existence;
We add a `@boundary` suffix to the filename cause the <pagePath> part is still need to use for indexing in the trie, but the `@boundary` doesn't matter yet. We'll remove it once we start using the file name in the dropdown panel

Closes NEXT-4330

### Example

When there's only one not-found.tsx, allow to trigger the not-found boundary and disable the rest.

https://github.com/user-attachments/assets/eb5c49a7-4fd2-496b-b778-fb66581908b3
2025-07-08 22:13:03 +02:00
9bbcfa2c14 Upgrade React from 5d87cd22-20250704 to a7a11657-20250708 (#81428)
Co-authored-by: Sebastian Sebbie Silbermann <[email protected]>
2025-07-08 19:09:00 +00:00
Cong-Cong PanandGitHub bdb87a1851 chore: update rspack to 1.4.5 (#81216)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

update Rspack to 1.4.2, in this version we fix bugs when using Rspack
persistent cache in next.js.

Now user can try Rspack persistent cache by follow way:

```js
const config = {
    webpack: (config) => {
        config.experiments.cache = {
            type: 'persistent'
        };
        return config;
    },
};
```
2025-07-08 17:57:38 +00:00
Sebastian "Sebbie" SilbermannandGitHub 76d9ab8e4e [test] Improve React performance track tests (#81359) 2025-07-07 16:04:53 +02:00
Sebastian "Sebbie" SilbermannandGitHub 39f5d0f32c [test] Dedicate suite for React's Server Request performance track (#81312)
We're testing this here since framework integration via `filterStackTrace` determines what React uses to determine the name of the Performance entry.
2025-07-06 11:47:17 +02:00
Hendrik LiebauandGitHub 2d19dc626b [dynamicIO] Use owner stacks for dynamic validation errors (#81277)
With recent improvements in React, and after switching to the React
builds for Node.js in #81048, we can now generate better dynamic
validation error stacks in dev mode by utilizing owner stacks instead of
component stacks.

For async I/O, we're using the owner stack exclusively. For sync I/O
we're appending the owner stack to the call stack. In a future iteration
we might instead log the original error as-is where it occurs, and let
`patchErrorInspectNodeJS` handle the owner stack appending as a general
solution.

Additionally, we're now guiding users in the build-time error messages
to using `next dev` for further debugging of dynamic validation errors –
or, alternatively, using `next build --debug-prerender`.

closes NAR-149
2025-07-04 22:09:23 +02:00
Sebastian "Sebbie" SilbermannandGitHub 8d78992557 [sourcemaps] Ignore-list sources whose sourcemaps ignore-list everything (#81231)
webpack-only at the moment since I have no easy stack to test this on in Turbopack until we sourcemap the Turbopack runtime.

This applies the same heuristic Chrome uses. For sources whose associated sourcemap ignores everyone of its sources, we ignore-list that source even if we didn't find a mapping. This is similar to other common heuristic where the closest mapping is used when no exact mapping exists.
2025-07-04 21:23:50 +02:00
Sebastian "Sebbie" SilbermannandGitHub c12c9c1f78 [test] Keep Playwright stackframes out of tests (#81240) 2025-07-04 10:24:02 +02:00
Sebastian "Sebbie" SilbermannandGitHub 7ed2d23ae5 [devtools] Omit line/col numbers for anonymous sources (#81223) 2025-07-03 15:23:27 +02:00
52b185d813 Upgrade React from 7216c0f0-20250630 to 73aa744b-20250702 (#81192)
Co-authored-by: Sebastian Sebbie Silbermann <[email protected]>
2025-07-02 18:16:23 +00:00
JJ KasperandGitHub 58bc2f112c Migrate usage of web-server in edge-ssr (#80915)
This continues the work for the `handlers` interface for the edge
runtime and re-uses the existing `route-module` interface we have
instead of initializing and using `web-server`/`base-server`.

Validated against our deploy tests
https://github.com/vercel/vercel/actions/runs/15987684940/job/45095833866?pr=13505
https://github.com/vercel/next.js/actions/runs/15987664161/job/45095390463
2025-07-02 10:18:13 -07:00
Jiachi LiuandGitHub 1e9f598ba6 [segment explorer] refactor boundary trigger with ui primitives (#81147) 2025-07-02 18:48:03 +02:00
Sebastian "Sebbie" SilbermannandGitHub 16e1e1455e [node-webstreams] Use React builds for Node.js (#81048)
Closes https://linear.app/vercel/issue/NEXT-4560/

React now exposes Web stream APIs in their Node.js builds so we can use the Node.js builds.

That enable us to use some of the Node.js goodies like `async_hooks` which is required for the React's experimental Server Requests track.

## Test plan

`next-server` runtimes did not increase bundle size. We even saved some in the `app-page` entries since we no longer have to bundle Edge and Node.js versions of React Server. We can rely solely on the Node.js variant of React Server.

A build of `test/e2e/app-dir/hello-world` shows no significant bundle size changes
2025-07-02 07:53:34 +02:00
Jiachi LiuandGitHub 19bf594b60 Revert "[devtool] merge segment explorer flag into panel ui flag (#81085)" (#81131)
Reverts #81085 to keep the flags separate so can test separately
2025-07-01 19:25:00 +02:00
Niklas MischkulnigandGitHub 7131d706ae Fix flakey devtools test (#81127)
A regression from #81085 @huozhi 


The problem is that `openDevToolsIndicatorPopover` doesn't tell anymore whether the popup menu is open, but if the panel is open, but the "Try Turbopack" text is in the popup menu (only in the old UI).
2025-07-01 18:01:18 +02:00
Jiachi LiuandGitHub 13401d8fd8 [devtool] merge segment explorer flag into panel ui flag (#81085) 2025-07-01 15:35:21 +02:00
Jiachi LiuandGitHub 82c85a5b7b [segment explorer] trigger boundary initial support (#80948) 2025-06-30 16:54:46 +02:00
Hendrik LiebauandGitHub 36930024ff Ignore JSON.parse <anonymous> (0:0) stack frames in test snapshots (#81044)
These frames will be ignore-listed soon. Until then, we remove them from the test snapshots, because their occurrence seems to be non-deterministic. They come from React's RSC parsing.
2025-06-29 15:35:04 -04:00
Jiachi LiuandGitHub 33477b7e64 [segment-explorer] display the builtin conventions (#80961)
Track built-in conventions in segment explorer. The default `global-not-found.js` and `global-error.js` will be displayed.
Their style will be different to the others, we'll follow up in the later PRs.

Closes NEXT-4576
2025-06-27 16:41:07 +02:00
Niklas MischkulnigandGitHub c2be57cc1d Turbopack: pass current Node.js version from JS side instead of invoking node (#80949) 2025-06-27 08:27:16 +02:00
Jiachi LiuandGitHub 71cdce68e0 [refactor] group the built-in conventions (#80957)
Group all the built-in conventions into `src/client/components/builtin` with the actual same name of the conventions they represent.

e.g. 
The default `not-found.js` is `next/dist/client/compoents/builtin/not-found.js`;
The default `global-error.js` is `next/dist/client/compoents/builtin/global-error.js`;

This give us an easier way to track all the builtin conventions. This is also the preparation work for #80961 where we display the builtin conventions in the segment explorer.
2025-06-26 23:36:57 +02:00
65e76eafbe Upgrade React from 197d6a04-20250424 to fa3feba6-20250623 (#80804)
Co-authored-by: Sebastian Sebbie Silbermann <[email protected]>
2025-06-26 16:12:52 +02:00
Luke SandbergandGitHub 8ba3a99a10 [turbopack] Add user friendly names to trace labels (#80388)
# Enhance Layer Names with User-Friendly Descriptions

This PR improves the developer experience by enhancing layer names in Turbopack with user-friendly descriptions. Instead of just using internal identifiers like "app-client" or "app-rsc", the PR adds descriptive names like "Client Component Browser" or "Server Component" that better communicate the purpose of each layer to developers.

Key changes:
- Created a new `LayerName` struct that contains both the internal name and an optional user-friendly description
- Updated all layer references throughout the codebase to use this new structure
- Changed error message text from "Example import trace(s)" to "Import trace(s)" for more simplicty

These changes make error messages and debugging information more intuitive, helping developers better understand which part of the application is experiencing issues.
2025-06-26 00:10:04 -07:00
Tim NeutkensandGitHub 5802ba8122 Turbopack Build: Implement browserslist for CSS / JS (#80603)
## What?

Implement browserslist for CSS / JS handling in Turbopack.

For JS it's not fully implemented yet, but for CSS it should be good
now.
2025-06-24 19:11:06 +02:00
Jiachi LiuandGitHub 6aa630c6ad [test] separate hmr env test (#80802) 2025-06-24 17:40:27 +02:00
Donny/강동윤andGitHub 52372be7cb build(turbopack): Update swc_core to v29.1.2 (#80659)
### What?

ChangeLog: https://github.com/swc-project/swc/compare/swc_core%40v27.0.6...swc_core%40v29.1.2

### Why?


To allow using https://github.com/swc-project/swc/pull/10625

### How?
2025-06-24 04:36:37 +00:00
72cc7db1bd fix to use https urls in meta data images when using experimental-https (#80276)
fixes #80275 

.. to generate https image urls in meta data when using the
--experimental-https flag

---------

Co-authored-by: Zack Tanner <[email protected]>
Co-authored-by: JJ Kasper <[email protected]>
2025-06-24 01:23:52 +00:00
Jiachi LiuandGitHub c54cc01902 [segment explorer] display default page in segment explorer (#80716) 2025-06-23 23:18:09 +02:00
Jiachi LiuandGitHub 8324d8108c [segment explorer] handle custom error boundary (#80714)
Display custom error boundary `error.js` in segement explorer when it's rendered

![image](https://github.com/user-attachments/assets/4abad442-0703-4609-8202-b4f41f007afe)

Closes NEXT-4331
2025-06-23 22:23:47 +02:00
Jiachi LiuandGitHub 9d4239a150 [segment explorer] handle display loading (#80698) 2025-06-23 21:03:17 +02:00
Jiachi LiuandGitHub 6e508d4f93 [segment explorer] display navigation error boundaries (#80691) 2025-06-23 18:08:02 +02:00
Jiachi LiuandGitHub 3981cccbe3 [segment explorer] handle custom global-error segment (#80685) 2025-06-23 17:36:20 +02:00
Jiachi LiuandGitHub 5771ce12f8 [segment explorer] handle builtin not-found (#80607) 2025-06-23 15:23:43 +02:00
Jiachi LiuandGitHub 9df0c8763c [segment explorer] handle edge and pages router (#80668) 2025-06-23 14:06:01 +02:00
Sebastian "Sebbie" SilbermannandGitHub da46d66667 Downgrade React from 79d9aed7-20250620 to 197d6a04-20250424 (#80762) 2025-06-22 09:07:44 +00:00
Sebastian "Sebbie" SilbermannandGitHub 322adb9835 [devtools] Fix Turbopack indicator (#80753) 2025-06-22 10:13:42 +02:00
Sebastian "Sebbie" SilbermannandGitHub 6a0b7e9059 Upgrade React from 197d6a04-20250424 to 79d9aed7-20250620 (#79477) 2025-06-20 15:47:45 +02:00
Jiachi LiuandGitHub f3d6af9525 [segment explorer] single row layout segment (#80576) 2025-06-18 16:16:19 +02:00
Zack JacksonandGitHub 8f2e058c24 test: fix failures caused by format discrepancies between rspack and other bundlers (#80314)
This pull request updates error recovery tests to improve compatibility
with the Rspack bundler by introducing an `isRspack` flag and modifying
test cases to handle Rspack-specific error formats. The changes ensure
that runtime and build errors are correctly detected and displayed when
using Rspack.

### Rspack Compatibility Updates:

* Introduced the `isRspack` flag to determine if Rspack is being used,
based on the `NEXT_RSPACK` environment variable. This flag replaces
direct checks of `process.env.NEXT_RSPACK` for better readability and
maintainability.
(`test/development/acceptance-app/error-recovery.test.ts`
[[1]](diffhunk://#diff-ed42d009889881804f76e500465e132e4aa1df75c8659119e1b5cff4d230b7cdR8-R9)
`test/development/acceptance/error-recovery.test.ts`
[[2]](diffhunk://#diff-18cc654bcba9dbffcf77a6157fec144f9d0b1a0b3c59d46b33f6a2b95f543a91R9)

* Updated test cases in `error-recovery.test.ts` and
`acceptance-app/error-recovery.test.ts` to handle Rspack-specific error
messages. This includes adapting error expectations for syntax errors,
runtime errors, and build errors with the Rspack error format.
(`test/development/acceptance-app/error-recovery.test.ts`
[[1]](diffhunk://#diff-ed42d009889881804f76e500465e132e4aa1df75c8659119e1b5cff4d230b7cdR58-R79)
[[2]](diffhunk://#diff-ed42d009889881804f76e500465e132e4aa1df75c8659119e1b5cff4d230b7cdR574-R588)
[[3]](diffhunk://#diff-ed42d009889881804f76e500465e132e4aa1df75c8659119e1b5cff4d230b7cdR845-R872);
`test/development/acceptance/error-recovery.test.ts`
[[4]](diffhunk://#diff-18cc654bcba9dbffcf77a6157fec144f9d0b1a0b3c59d46b33f6a2b95f543a91L58-R74)
[[5]](diffhunk://#diff-18cc654bcba9dbffcf77a6157fec144f9d0b1a0b3c59d46b33f6a2b95f543a91L372-R394)
[[6]](diffhunk://#diff-18cc654bcba9dbffcf77a6157fec144f9d0b1a0b3c59d46b33f6a2b95f543a91L755-R766)

* Replaced outdated error message formats in Rspack-related test cases
with updated and more precise error descriptions, including detailed
stack traces and error causes.
(`test/development/acceptance/error-recovery.test.ts`
[[1]](diffhunk://#diff-18cc654bcba9dbffcf77a6157fec144f9d0b1a0b3c59d46b33f6a2b95f543a91L815-R835)
[[2]](diffhunk://#diff-18cc654bcba9dbffcf77a6157fec144f9d0b1a0b3c59d46b33f6a2b95f543a91L883-R903)

These changes improve test coverage for Rspack and ensure robust error
handling across different bundlers.
2025-06-17 04:28:14 +00:00
Donny/강동윤andGitHub 7e310f8d2a fix(turbopack): Improve error message for PURE selector error (#80068)
### What?

Use CSS string for CSS errors instead of Rust debug representation, and remove `lightningcss` text from the error message.

### Why?

We don't need them.
2025-06-12 22:44:36 +00:00
Jiachi LiuandGitHub f8add0d9ff [segment explorer] fix soft navigation case (#80443) 2025-06-12 13:10:33 +02:00
Sebastian "Sebbie" SilbermannandGitHub ae1f0be351 [segment-explorer] Signal updates to React (#80316)
We never actually invoked the listeners attached by React. Updates only worked on soft-navigation because we also re-render the DevOverlayRoot and don't bail out anywhere at the moment.

Just invoking the listeners is not sufficient after https://github.com/vercel/next.js/pull/79699 since userspace and dev-overlay would read different versions of `listeners`. I ported the segment explorer into the new folder structure. Updates now flow through the `dispatcher` and then invoking the listeners actually works. Though mid term we should move the segment tree into actual React tree to get rid of the sync updates.

I also noticed that we're missing an implementation for a remove operation which is required to show the correct state during soft navigations.
2025-06-12 12:48:08 +02:00
Jiachi LiuandGitHub 737d3199c6 [segment-explorer] optimize tree view (#80392) 2025-06-11 18:21:10 +02:00
Jiachi LiuandGitHub cf1f47a5d1 [dev-overlay] fix duplicate re-render of errors (#80322)
### What

When there's a same error throwing constantly, we should avoid unnecessary re-renders on the exact same error. In dev overlay we already have strategies that can dedupe the error. And we noticed the error is shown correctly but just the dialog got re-rendered with animations.

After digging deeper, noticed we are still adding the same runtime error into the error collection, just because each time it got the new "ID", as the "ID" itself is incremental based on actions. Each action will get a new error ID. Hence we're adding a condition in deduping. If we found that the new error already existed in the previous events, we'll return with the same previous events instance to tell dev overlay that errors are not changed.

Fixes NEXT-4493

#### After
https://github.com/user-attachments/assets/c1f004b5-2de6-445a-aad0-efdfd0ecb8c9

#### Before
https://github.com/user-attachments/assets/1249ed54-ba63-4eb6-a08a-64560ab4014a
2025-06-10 11:42:20 +02:00
Luke SandbergandGitHub 19e8e3c3c2 Revert "Revert "[turbopack] Compute Import Traces for Issues"" (#80220)
Reverts vercel/next.js#80215 which was a revert of vercel/next.js#79351

Closes PACK-4105
2025-06-07 15:28:07 -07:00