- 06 Sep, 2025 2 commits
-
-
nextjs-bot authored
-
Zack Tanner authored
When using an unsupported API in a route handler (eg, `export const dynamic` with `cacheComponents` enabled), we were not erroring in dev or failing the build. This is because the transform only asserted on pages & layouts, and not route handlers. This updates the handling to also check route handlers. Fixes NAR-371
-
- 05 Sep, 2025 12 commits
-
-
nextjs-bot authored
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Hendrik Liebau authored
In dev mode, React is sending debug info (owners, stacks, console logs etc.) from the server to the client so that they can be displayed in dev tools. By default, this info is sent as part of the main RSC payload (inlined into the HTML, or fetched after interaction). With this PR, we're now transporting the debug info in a separate debug channel. This channel currently consists of a unidirectional stream (writable on the server, readable in the client) that is serialized as binary WebSocket messages, which are sent through the existing WebSocket connection that Next.js uses for HMR messages etc. In a follow up, we will also implement the return channel (writable in the client, readable on the server). This allows the client to retrieve debug info lazily and on demand during inspection/introspection. One benefit of this approach is, that it will allow us to change our dynamic validation strategy. We should then be able to tee and cut off the dynamic RSC stream at different points in time (representing the static prerender, runtime prerender, and dynamic render stages), while still letting the complete debug info stream in through the separate channel. This allows us to show the same dynamic validation error details as before, while reducing the number of renders needed to accomplish that. For dogfooding purposes, the feature can be disabled by setting `experimental.reactDebugChannel` to `false`, in case of unexpected regressions in dev mode. ### An implementation note on the request ID handling On the server, at the beginning of the rendering process, we determine a `requestId` and an `htmlRequestId`. 1. The `requestId` is a UUID that's newly generated for each incoming request. 2. The `htmlRequestId` is one of two things: 1. For the HTML request, it's the same as the `requestId`. 2. For subsequent RSC requests (for navigations or server actions), it's the ID of the HTML document from where the request originates. It is sent as the `x-nextjs-html-request-id` request header. The HTML request ID is used to identify connected WebSocket clients. It's sent to the browser as the global `__next_r` variable in the script tag that also includes the initial RSC instructions. The browser sends it back to the server as `id` query param of the WebSocket request. On the server, we store the clients by HTML request ID. When debug chunks are sent to the browser, we use the HTML request ID to look up the correct client. (There's only one client per browser tab/window.) In the browser, we create a debug channel for each request, and we store them keyed by request ID. For the HTML request, the request ID from `__next_r` is used as key. For the RSC requests, the `requestId` is received as `x-nextjs-request-id` response header, and used as key. The server sends the current request ID as part of the WebSocket message to the browser, so that the chunks can be enqueued into the correct debug channel. closes NAR-310 -
nextjs-bot authored
-
Josh Story authored
Prerender interrupted errors are part of the control flow for Next.js applications and aren't intended to be caught by user code. Since we can't avoid it we need to include it in the rethrow API.
-
Jiachi Liu authored
-
Sebastian "Sebbie" Silbermann authored
-
Tim Neutkens authored
## What? Changes in #83331 accidentally changed behavior of how `tsconfig.json` is resolved. When using Next.js we don't want it to be resolved relative to the current file being compiled. It should only use the application root. This PR fixes the behavior to match what it was before and adds a test that fails if it breaks again.
-
Jiachi Liu authored
-
Luke Sandberg authored
This is needed by `prepared_app.rs` to manage subprocesses. Without this we are seeing build breakages in CI e.g https://github.com/vercel/next.js/runs/49662155436 This was triggered by the nix upgrade in #83414
-
Luke Sandberg authored
[turbopack] RFC: Serialize turbopack objects as u16s instead of fully qualified symbol names (#83193) Change the serialization strategy for `ValueTypeId`, `TraitTypeId` and `NativeFunction` to use `u16` values instead of the `global_name` (a fully qualified name of the object). For all these objects the value is the index+1 of the corresponding object in the set of all objects sorted by name. This is a deterministic ordering which should ensure we can deserialize them with the same version of turbopack. Potential concerns with this approach: * debuggability in the Persistent Cache (is this even a thing?) * stability of ids across architectures * if different architectures enable/disable turbotasks then ids will change and make the PC database non-portable. Still this should speed up serialization/deserialization by making everything smaller and faster to encode/decode On an optimized build with a fresh `.next` directory, i measured the size of the `.cache/turbopack/vxxxx` directory `benches/module-cost`: change: 2.38Gb (-22%), wrote in 9.5s, compacted in 5.4s head: 3.06Gb bytes, wrote in 10.3s, compacted in 7.6s `vercel-site` change: 4.8Gb(-12%), wrote in 46ss, compacted in 6.2s head: 5.5Gb, wrote in 48s, compacted in 7.6s So a non-trivial size reduction as expected. This should also speed up encoding/decoding but i didnt attempt to directly measure that. -
Luke Sandberg authored
We are experiencing https://github.com/rust-lang/rust-analyzer/issues/19993 and Rust Analyzer is complaining about our macro gencode. After some trial and error i determined the issue was our use of the `concat!` and specifically the inclusion of the crate name macro so this works around that. Apparently Rust Analyzers implementation of concat! or maybe token tree parsing can get confused by string literals with `-` characters in them. Simply avoiding that for rust analyzer is a reasonable short term workaround
-
- 04 Sep, 2025 26 commits
-
-
nextjs-bot authored
-
Niklas Mischkulnig authored
- Remove dead code back from the old days - Update a few crates Codspeed didn't really have anything breaking in v3? https://github.com/CodSpeedHQ/codspeed-rust/releases
-
Luke Sandberg authored
### What? In #83074 we changed how turbo task objects were registered to use the `inventory` crate. This PR adds a new `inventory_submit!` macro that wraps the existing `inventory::submit` function with a `#[cfg(not(rust_analyzer))]` attribute to prevent Rust Analyzer choking on the generated code. See example error  Because the inventory code does not affect any API surfaces this is safe and if anything should improve rust-analyzer performance
-
Luke Sandberg authored
Confirms that we don't re-evaluate modules after an error Clearing the require.cache allows us to re-evaluate
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack.
-
Luke Sandberg authored
# Improve symlink handling in turbo-tasks-fs This PR enhances symlink handling in the filesystem layer to better handle error cases and provide more detailed error messages. The key changes include: - Refactored `realpath_with_links` to return a more structured error instead of silently returning the input path when hitting a resolution error - propagate this through the callers - Improved `DirectoryEntry::Error` to include error messages instead of just signaling an error occurred - Enhanced `resolve_symlink()` to handle more edge cases like dead symlinks These changes make the system more robust when dealing with complex symlink scenarios, including symlink loops, dead links, and excessive symlink chains. A few customers have hit errors where broad tailwind globs cause turbopack to navigate through symlinks that trigger crashes, this is due a a few reasons: * a symlink pointing at a non-existent file. * a symlink pointing outside the filesystem root This can happen with certain package managers and we need to be defensive. For `track_glob` we just want to track matching files and directories, but we don't want to navigate out of the filesystem so just ignore links that trigger these conditions. Closes PACK-5383 One interesting thing is that `read_glob` does not resolve symlinks, and therefore doesn't trigger the errors, that behavior is unchanged. -
nextjs-bot authored
-
Janka Uryga authored
If we're navigating to a page without a prefetch, we obviously can't show an instant loading state. However, if the page has a `loading.tsx`, then the loading component will still stream in as part of the dynamic response, and we should use it to render a loading boundary around the page content. If we don't, then the navigation will block until the content resolves into something renderable (either finishes or manages to render a suspense boundary of its own). This wasn't being done because `createPendingCacheNode` (used for unprefetched navigations) was always setting `loading` to `null`, and then was never updated with the `loading` received from the dynamic response. With this PR, if we don't already have a prefetched loading state, we'll now handle `loading` the same as we do `rsc` (the segment's content) -- we'll create a deferred promise for `loading` and resolve it when the relevant segment streams in. Note that before the deferred promise is resolved, the relevant `LoadingBoundary` itself will suspend on it, but since it sits right above `rsc` (and is in a new subtree) we won't hide any more contents than we would when suspending on the `rsc` promise -- we don't have a prefetch, so we won't have an existing loading state to display there anyway. Also I had to do some typescript tweaks to `createDeferredRsc` to allow it to contain a more specific type than `ReactNode`. it's a bit noisy, so that's pulled out into a separate commit for ease of review.
-
Trevor Burnham authored
Co-authored-by:Jiachi Liu <inbox@huozhi.im>
-
Janka Uryga authored
The merge driver for `errors.json` has been around for a while, and seems to work without issues. This PR enables it by default by installing it in `postinstall`(via the existing `git-configure.mjs` script which is invoked from there already) It also adds `scripts/merge-errors-json/uninstall` to temporarily disable it in case of issues. If the driver crashes, we'll also print instructions on how to disable it.
-
Honda Yuto authored
Co-authored-by:Jiachi Liu <inbox@huozhi.im>
-
Jiachi Liu authored
-
Steven authored
The Image component's existing `priority` prop is confusing since its not obvious what it does. In order to improve clarity, we are introducing a `preload` prop and deprecating the `priority` prop. We also updated the dev warning to no longer suggest using this prop for the LCP and instead use `loading="eager"`.
-
Jiachi Liu authored
-
Jiachi Liu authored
-
nextjs-bot authored
-
Hendrik Liebau authored
-
Jiachi Liu authored
-
Niklas Mischkulnig authored
For `next build` and `next dev`, log that webpack is used ``` ▲ Next.js 15.5.1-canary.26 (webpack) Creating an optimized production build ... ✓ Compiled successfully in 1244ms Linting and checking validity of types ..
⚠ The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config ✓ Linting and checking validity of types ✓ Collecting page data ✓ Generating static pages (3/3) ✓ Collecting build traces ✓ Finalizing page optimization ``` -
Tim Neutkens authored
## What? These values were only provided to emit events and not for the actual handling of jsconfig/tsconfig `paths` and such, those are handled separately by Turbopack itself. This removes the events as they're no longer relevant and it's not worth slowing down dev/build for them.
-
Niklas Mischkulnig authored
On Vercel, we only need `next-minimal-server.js.nft.json` Also, `ci_has_next_support` was implemented correctly, it previously read from `nextConfig.env`, instead of the real (full) environment variables from the system.
-
Tim Neutkens authored
## What? Preparation for swapping the special logic in `start()` to using `build()` directly. The build() method now respects buildCommand and `NEXT_SKIP_ISOLATE` settings that it previously ignored.
-
Niklas Mischkulnig authored
`/tmp/package-lock.json` messes up the tests because it influences the build root auto detection.
-
Tim Neutkens authored
## What? This test incorrectly using internals instead of the public api. Switched it to using the custom server api.
-
Niklas Mischkulnig authored
Closes PACK-5382 Previously, Turbopack validated every single module for route segment config, leading to false positives (on non-page files) and worse build performance. There were also three separate implementations of this logic. Now, all of these cases are fatal errors, not just warnings. Examples for errors ``` ./bench/basic-app/app/export/inherit/page.tsx:1:28 Next.js can't recognize the exported `preferredRegion` field in route. It needs to be a static string or array of static strings. > 1 | export { default, runtime, preferredRegion } from '../basic/foo' | ^^^^^^^^^^^^^^^ The exported configuration object in a source file needs to have a very specific format from which some properties can be statically parsed at compiled-time. https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config ``` This error message is slightly different now: ``` browser log: ./test/integration/app-dir-export/app/another/[slug]/page.js:6:8 Next.js can't recognize the exported `generateStaticParams` field in route. App pages cannot use both "use client" and export function "generateStaticParams()". 4 | 5 | > 6 | export function generateStaticParams() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 7 | return [{ slug: 'first' }, { slug: 'second' }] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 8 | } | ^^ 9 | 10 | export default async function Page(props) { 11 | const params = await props.params The exported configuration object in a source file needs to have a very specific format from which some properties can be statically parsed at compiled-time. Import traces: Client Component Browser: ./test/integration/app-dir-export/app/another/[slug]/page.js [Client Component Browser] ./test/integration/app-dir-export/app/another/[slug]/page.js [Server Component] Client Component SSR: ./test/integration/app-dir-export/app/another/[slug]/page.js [Client Component SSR] ./test/integration/app-dir-export/app/another/[slug]/page.js [Server Component] https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config ```
-