- 15 Oct, 2026 30 commits
-
-
next-js-bot[bot] authored
-
Josh Story authored
## Summary Pass the final app-page request URL explicitly from the Node, Edge, and build export entry points into rendering. This keeps URL parsing and the deterministic prerender request ID tied to the exact URL observed on the request after existing normalization. Development ISR status bookkeeping uses the forwarded URL with its existing URL parsing behavior. A path-scoped lint guard prevents new direct `req.url` reads in app-render. ## Verification - `pnpm --filter=next types` - `pnpm --filter=next build` - Confirmed `rg -n '\breq\.url\b' packages/next/src/server/app-render` has no matches. - ESLint stdin probes reject `req.url` under app-render with the `requestUrl` guidance and allow the same access outside app-render. - Not run: integration tests (the worktree lacks per-package dependencies, so the full bootstrap build could not complete). <!-- NEXT_JS_LLM -->
-
Sam Selikoff authored
Hide "Open in editor" button text on small screens. Follow-up to #100206. <!-- NEXT_JS_LLM -->
-
Niklas Mischkulnig authored
Basically reverts https://github.com/vercel/next.js/pull/63683 API routes don't have "parent layouts" and shouldn't inherit their config from anywhere
-
Niklas Mischkulnig authored
Add some regression tests about the current behavior Mostly - inheritance across layouts and parallel routes - API routes Turbopack is currently wrong for some of those. See PRs up the stack
-
Andrew Clark authored
If an entry is not partial, it means nothing was omittted during rendering. Regardless of the strategy used to fetch it — static vs dynamic, shell vs prefetch vs navigation, etc — it's the most complete possible representation of the data. No other fetch strategy could return a more complete version. This PR updates the precedence logic to take `isPartial` into account. I discovered this while working on the next PR, which replaces `isPartial` with a new "completeness" concept. I extracted it into this earlier PR to show how it would be expressed in the current model, so the next one is easier to review.
-
Andrew Clark authored
A navigation response that includes dynamic data should not report any vary params, because (until the Ledgers feature lands in React), we cannot track params during a streaming render. This updates the server to send `null`, which represents an unknown set of params. The previous structure was mostly harmless because the client only uses the vary params when writing to its local cache, and navigation responses are not written to the cache (except when they are fully static). The one exception is when performing a full prefetch when Partial Prefetching is not enabled — the client had a special case to ignore the (bogus) vary params sent by the server and treat them as unknown. The special case is no longer necessary after this fix. Now the server's vary params can be treated as authoritative in all cases without special handling on the client.
-
Andrew Clark authored
Fixes a few oversights in the Partial Prefetching implementation that I discovered while working on a larger refactor. I've moved these into a separate PR so they can be reviewed independently of the upcoming restructuring. These can be reviewed commit-by-commit.
-
Andrew Clark authored
Fixes an oversight in the Cached Navigations implementation where a fully cached navigation response was written into the cache without also extracting and writing its shell.
-
Andrew Clark authored
Navigation and prefetch requests go through `createFetch`, which had grown several jobs beyond fetching. It decoded navigation responses itself (so React DevTools could time the request from the moment it was sent), with a flag for prefetches to opt out and a separate wrapper stream for HMR refreshes that can be superseded. With Cache Components, it also stripped the leading partial marker byte by rebuilding the Response around the stripped stream, and tee'd every response so a full prefetch could cut its shell from a second copy of the body. Every caller paid for the tee and the rebuilt Response, including ones that never needed them. This PR untangles those layers. Each commit can be reviewed on its own. This is mostly a restructuring, to make the subsequent PRs in the stack easier. No meaningful outward behavior changes.
-
Andrew Clark authored
The original `cachedNavigations` experiment had a behavior where if the feature was not enabled for a particular route, the client would cache just the static part of the response, since it could be expressed as a single byte offset without any additional overhead. We've since decided Cached Navigations is too important of a feature to be opt-in per route. So now it's always enabled (whenever Partial Prefetching is enabled). Therefore it no longer makes sense to extract the static part of the response. Instead, we'll do the same thing prefetch responses do, and extract out the shell, since the shell can be reused across different params values for the same route. This commit starts by removing the static stage extraction from the client. Subsequent steps will unify Cache Navigations extraction with the corresponding part of the prefetching implementation. When Partial Prefetching is enabled, every navigation response can be written into the cache: either the entire response is cachable, or it contains an embedded inner response that is cacheable. Conceptually it's as if each navigation is accompanied by a corresponding prefetch, and both requests are returned in the same response. This unifies the implementation used to write the response (whether it comes from a navigation or a prefetch) into the client cache.
-
Andrew Clark authored
When working on some upcoming refactors of the prefetching implementation, I discovered some cases scenarios where we didn't have test coverage of non-Partial Prefetch behavior. This adds new tests to ensure the behavior does not regress: - A `prefetch={true}` link fetches only the dynamic data that a default prefetch of the same URL left out, and a default link doesn't re-request what a `prefetch={true}` link already fetched. - Back/forward navigations are served from the back/forward cache without requests. - A loading-boundary prefetch counts as complete for the segments above the boundary, so the navigation requests only the page below it. -
Sam Selikoff authored
Make the "Open in editor" button easier to discover in the error overlay. Updates the icon to a Code Wrap icon from Geist. <img width="1984" height="788" alt="image" src="https://github.com/user-attachments/assets/5e633c6a-f4cd-48f9-8925-b42981f20a4b" /> <!-- NEXT_JS_LLM -->
-
Niklas Mischkulnig authored
Fix ``` $ pnpm i [WARN] The "workspaces" field in package.json differs from "packages" in pnpm-workspace.yaml. pnpm uses pnpm-workspace.yaml. ```
-
Joseph authored
## Summary The Pages Router docs had no version 15 or 16 upgrade guides. This adds both as `source:` stubs that render the App Router guides, and gates the App Router-only sections with `<AppOnly>`. - Version 15: Async Request APIs, `runtime` config, `fetch` caching, Route Handlers, and Client Cache are App Router only. The React 19 minimum is App Router only; a `<PagesOnly>` bullet notes the Pages Router supports React 18 and 19. - Version 16: Async Request APIs, async metadata image and sitemap params, React 19.2 (Canary), Caching APIs, routing and navigation, PPR, parallel routes `default.js`, and the `dynamicIO`/`useCache`/`unstable_rootParams` removals are App Router only. Scroll Behavior Override stays shared (the Pages Router uses the same helper) and gets a `pages/_document.tsx` example. - App Router-only checklist items move to an `<AppOnly>` block at the end of each checklist. ## Verification - Not run: `prettier` (local install is broken; committed with `--no-verify`, CI lint covers it) <!-- NEXT_JS_LLM -->
🤖 Generated with [Claude Code](https://claude.com/claude-code) -
Joseph authored
## Summary In `next dev`, `'use cache: private'` results are stored in memory, keyed by the request's cookies and headers, and served to the next matching request while a fresh result is generated in the background (#94694). The reference page only described production, where results are not stored across requests, so a reload in dev that showed the previous result looked like a bug. This adds one sentence describing the dev behavior. Finding: https://next-maintainer-agent.vercel.tools/agent-feedback/2068 <!-- NEXT_JS_LLM -->
-
Niklas Mischkulnig authored
- Run three more test suites with Turbopack as well - Delete test/production/typescript-custom-tsconfig. It was only checking stdout (and not actual behavior), and we have multiple other tests for `nextConfig.tsconfigPath` anyway: test/e2e/tsconfig-path, test/e2e/typescript-custom-tsconfig, test/production/app-dir/typescript-cli
-
next-js-bot[bot] authored
-
next-js-bot[bot] authored
[diff facebook/react@07dde64d...99c106c4](https://github.com/facebook/react/compare/07dde64d...99c106c4) <details> <summary>React upstream changes</summary> - https://github.com/facebook/react/pull/37852 - https://github.com/facebook/react/pull/37850 - https://github.com/facebook/react/pull/37846 - https://github.com/facebook/react/pull/37764 </details> --------- Co-authored-by:
next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com> Co-authored-by:
Josh Story <gnoff@storyposted.com>
-
Niklas Mischkulnig authored
Fix ``` Run vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 Exchange GitHub OIDC token for Vercel access token Error: OIDC environment variables are missing. The calling job needs "permissions: id-token: write". Error: Process completed with exit code 1. ```
-
Niklas Mischkulnig authored
## Summary Fix lost binary-trace self-time when a span re-enters itself on the same thread, as happens with instrumented futures. Previously, the inner Exit restarted the outer frame's clock under the same `(span_id, thread_id)` key and immediately removed it, dropping the outer frame's remaining work. Store the active slice start on each per-thread stack frame instead. Enter closes the current top's slice; Exit closes the matching frame and resumes the new top only when the exiting frame was on top. Non-LIFO exits remove suspended frames without restarting another clock; unmatched exits leave clocks unchanged. Allocation attribution, queued-parent processing, and `DROP_SPANS` remain intact. **Binary flame CPU/self-time, concurrency-corrected time, and concurrency metrics will change because the previously missing slices are now accounted for correctly.** This does not change the binary trace format. Add encoded `TraceRow` parser regressions for single/multiple same-span nesting, child interleaving, cross-thread activity, non-LIFO/unmatched exits, live input with a partial final row, allocations, queued parents, and dropped spans. Five regression cases failed against the original reader before the fix. ## Verification - `cargo test -p turbopack-trace-server` — 84 library and 58 binary tests passed. - `cargo clippy -p turbopack-trace-server --all-targets -- -D warnings` — passed. - `cargo fmt --all -- --check` — passed. - Generated a real binary trace from a small local app using published `16.5.0-canary.10` with `NEXT_TURBOPACK_TRACING=turbo-tasks`: 2,282,825 rows, 652,508 Enter/Exit pairs, 11 threads, and 109,050 same-span re-entries; all exits LIFO. - Independently decoded the raw postcard rows with a standalone decoder and reconstructed slices using per-thread span-ID stacks and transition timestamps. Of 1,118,980 physical positive frame slices, five were intentionally excluded by existing thread/blocking-span rules. The remaining **1,118,975-slice multiset matched exactly** in both Store events and `self_time_tree`, including ownership and start/end timestamps. Independent self-time, stored self-time, and root flame CPU total all equaled **11.537977 CPU seconds**. No trace payload or local app files are included. - Repository-wide `pnpm build-all` bootstrap could not start because this checkout has no `node_modules` (`turbo: command not found`); the Rust checks above ran successfully. <!-- NEXT_JS_LLM --> <!-- fleet 8e507624-bae8-4561-8469-867912a2654e --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
-
Yousef Dawood authored
### What? Adds a "Testing instant navigations" section to the Playwright guide. It covers the `instant()` helper from `@next/playwright`: how to install it, an example test, and how to enable the testing API when running tests against a production build. ### Why? The `instant()` helper is documented in the Instant navigation guide and the `instant` API reference, but the Playwright guide never mentions it. People who come to this page to learn how to test Next.js apps with Playwright won't find out that a helper exists for catching regressions in instant navigations. ### How? - Adds a new section at the end of the Playwright guide, wrapped in `<AppOnly>` because the feature requires Cache Components. - Includes the install command, an example test using `instant()` with `page.waitForURL()`, a note about passing `baseURL`, and the `exposeTestingApiInProductionBuild` config for production builds. - Content is based on the existing official docs: - https://nextjs.org/docs/app/guides/instant-navigation - https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/instant - https://nextjs.org/docs/app/api-reference/config/next-config-js/exposeTestingApiInProductionBuild
-
Joseph authored
## Summary Follow-up to #100196. `error.js` and `global-error.js` receive whatever was thrown: Server Component errors arrive as an `Error`, but a value thrown in a Client Component is passed through as-is. The docs annotated the prop as `Error & { digest?: string }` and described it as always an `Error`. - `error.mdx` and Getting Started > Error Handling: type `error` as `unknown` in the `error.tsx` and `global-error.tsx` examples, and describe the prop as the thrown value, with a note to narrow before reading `message` or `digest`. - `with-stripe-typescript`: the three `error.tsx` boundaries narrow with `instanceof Error`. The component is renamed from `Error` to `ErrorPage` so it no longer shadows the global. <!-- NEXT_JS_LLM --> -
next-js-bot[bot] authored
-
Tobias Koppers authored
> [!NOTE] > Stacked on #100165. Compare against `codex/net-collectibles-in-from-task`. ### What? Split `entrypoints_without_collectibles_operation` into two root operations: - **`inner_entrypoints_without_collectibles_operation`**, a function nested inside the outer operation, contains the previous body: `strongly_consistent` resolve, `drop_issues()`, `take_effects()`, then `connect()`. Its long name is kept so it is easy to identify in traces. - **`entrypoints_without_collectibles_operation`** keeps its name and signature, and only connects the inner operation. `EntrypointsOperation::new` and all `pick_*` operations are unchanged. ### Why? During `next build`, ~6,000 `pick_*` root operations connect to `entrypoints_without_collectibles_operation`. - **Problem:** that task drops the issues and takes the effects of the entrypoints subgraph. It therefore holds an own negative count for each of them alongside the positive aggregated counts. Each new `pick_*` upper receives a copy of all of those collectibles. #100165 nets them outside the follower lock, but the copy remains. - **Fix:** moving the drop/take into an inner root operation keeps those negative counts in the inner task. The outer task, which the `pick_*` roots connect to, should then have no (or only very few) collectibles to copy into each of them. This is reasoning from the code; I didn't measure the per-task collectible counts. ### How? **Measurement** against #100165 (`acba773c`): `bench/nested-deps-app-router-many-pages`, 32 CPUs, cold untraced `next build`, 1 warm-up plus 4 interleaved rounds per arm. | Metric | #100165 median | this PR median | median paired change | |---|---:|---:|---:| | `turbopack-emit` | 8.27 s | 5.24 s | **−37.5%** | | "Compiled in" | 29.85 s | 26.80 s | −10.2% | | wall | 50.51 s | 46.55 s | −7.9% | All three metrics were faster in all 4 rounds. **Equivalence with #100165:** - The `.next` output has the same file set. After normalizing build IDs and timings, only the known per-build random keys differ. - Warning and error fixtures produce identical normalized issue output. **Local checks:** `pnpm build-all` passes (18/18 tasks), as do `next-api` clippy with `-D warnings` and rustfmt. **Limitations:** - One VM and four rounds, with no significance test. - I didn't add a trace or a direct collectible-count probe. - I didn't test dev/HMR or incremental rebuilds locally. <!-- NEXT_JS_LLM --> <!-- fleet d8fee2f9-18db-4936-b59a-f8417b8f4bbc --> --------- 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>
-
Tobias Koppers authored
### What? Net the collectible counts of an `AggregatedDataUpdate` in a new `AggregatedDataUpdate::optimize()`, called after the follower task's lock has been released. ### Why? When an aggregating task gains (or loses) an upper, `AggregatedDataUpdate::from_task` builds an update from the task's own collectible counts plus `+1` for every positive aggregated collectible. - **Cancelling entries:** a task that takes or drops the collectibles of its subgraph holds an own `-1` for each of them, so most of those entries cancel out. An earlier large `next build` investigation found one such update with 106,268 entries, of which only 4 had a nonzero net count. - **Serialization:** in a large `next build`, ~6,000 uppers connect the same task. `from_task` runs while that follower's lock is held, so anything done per update while the lock is held serializes across all workers. - **Why the earlier version didn't help:** a previous version of this PR netted inside `from_task`, still under the lock. It didn't improve emit time. ### How? - **`from_task`:** back to its original form (own entries, then `+1` per positive aggregated entry). It keeps a `Vec::with_capacity` upper bound so the vector isn't reallocated while the task is locked. - **`optimize()`:** sums the collectible entries per collectible, drops zero sums, and keeps the dirty container update unchanged. It reuses the vector's allocation. - **Call sites:** `optimize()` is called right after the follower lock is dropped, at the sites that apply the update to uppers afterwards. These are the new-follower paths and the lost-follower paths. In the lost-follower paths, `invert()` also moved out of the lock, after `optimize()`. The `balance_edge` paths, which hold both locks through `apply`, are unchanged. - **Semantics:** applying the optimized update (or its inversion) gives the same final counts in the upper, and the same set of collectibles whose presence changes. Intermediate flips within one update can be skipped. Result order is unspecified. **Tests:** - Unit tests for summing, cancellation, mixed counts, empty and single entries, and disjoint keys. - Equivalence of final counts and presence changes for add and invert. - The real `optimize().invert()` path on `CollectibleRef`s, including the dirty container update. - An integration test that reads an operation which takes its child's collectibles, through several root uppers. **Measurement** on canary `8521c6ae` (`bench/nested-deps-app-router-many-pages`, 32 CPUs, cold untraced builds, 1 warm-up plus 4 interleaved rounds, median of the paired per-round changes vs canary): | | change | |---|---:| | `turbopack-emit` | **−32.2%** (17.4 s → 11.9 s) | | "Compiled in" | −11.2% | | wall | −10.0% | All three were faster in all 4 rounds. Output (`.next` file set) and issues are unchanged vs canary. This is one VM and 4 rounds, and the gain isn't broken down between the preallocation and moving work out of the lock. <!-- NEXT_JS_LLM --> <!-- fleet d8fee2f9-18db-4936-b59a-f8417b8f4bbc --> --------- 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>
-
Andrew Imm authored
Fixes #99114 in both Turbopack and Webpack Due to Google Fonts dynamically returning the "best" font for the UA, it sometimes comes back as WOFF2 without an extension. We hardcode an extension expectation, so this fails: Webpack assumed every font URL ended in an extension, causing a null-regex crash. Turbopack split JSON options at embedded `&` characters. After that, its extension check would also fail The solution: For Webpack, remove the unsafe dereference, and resolve the extension from the CSS `format('XYZ')` hint when the URL lacks an extension For Turbopack, carry the resolved font extension from CSS extraction into asset emission instead of requiring a URL suffix. Also while investigating, Fleet found another bug: it parses the serialized options as a query string, so embedded `&` characters split the options before it ever reaches the extension check. To fix, we now percent-encode the entire JSON as one query entry, preserving the embedded params. --------- Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Andrew Imm <494043+andrewimm@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Tobias Koppers authored
### What? With `cacheComponents` and the default `experimental.turbopackSharedRuntime`, a Turbopack production build breaks hydration under a nonce-based CSP (`script-src 'self' 'nonce-…'`). The route's inlined chunk-group bootstrap ends up in the prerendered static shell without a nonce. The browser blocks it, the Turbopack runtime never starts the entry, and the page stays non-interactive. This PR emits that bootstrap from the per-request part of the response instead, where the request's nonce is known. The shared runtime stays on by default. ### Why? Since 16.4 the shared runtime replaces the per-route evaluate chunk with an inline `globalThis.TURBOPACK.push({ otherChunks, runtimeModuleIds })` script, passed to React as `bootstrapScriptContent`. A PPR static shell is rendered at build time: there is no request, so React has no nonce to put on it. The shell can't be fixed when it's served either. On Vercel the proxy serves the cached shell before any Next.js code runs, and only the resumed dynamic stream is rendered per request. So the bootstrap has to come from that stream. ### How? **Server.** Cache Components prerenders now keep the Turbopack bootstrap separate from the other bootstrap content, such as the Instant Navigation testing script, and leave it out of the shell. - For a postponed shell, the resume emits it as an inline script with the request nonce, right before the inlined Flight data. This reuses the existing data-injection pipeline, so the ordering is the same as today: after the first HTML chunk for empty preludes, and for HTML- and data-postponed state on both the Node and web stream paths. - A complete prerender emits it the same way, as part of the stored response. - Fully dynamic renders and non-Cache-Components prerenders keep using React's `bootstrapScriptContent`. - The paths that serve a postponed shell without a resume (the Instant Navigation testing lock and `__nextppronly` shell debugging) append the bootstrap themselves. **Client.** A bootstrap pushed after the shared runtime has loaded is registered from inside that inline script. There, `document.currentScript` has no `src`, so `appBootstrap()` threw `Invalid URL` while deriving the asset prefix. That prefix is only used by the dev server's HMR WebSocket, so it's now only derived on the dev server. Dev behavior is unchanged. **Not covered:** - React's own `$RT` timing script in the static shell still has no nonce, so a nonce CSP still reports that one violation. It doesn't affect hydration, and it was already blocked before 16.4. - Fully static pages under a nonce CSP are unchanged; their inline Flight data has no nonce either. ### Tests New e2e suite `test/e2e/app-dir/ppr-shared-runtime-csp-nonce`. It runs on Turbopack production builds only (`@force-gate !dev && turbopack`) and covers: - the shell contains no bootstrap, and the resume contains it exactly once with the request nonce - the nonce is also picked up from a report-only CSP, and there is no nonce without a CSP - the page hydrates under a nonce CSP - the page hydrates when the bootstrap runs after the shared runtime and all entry chunks have loaded. The test forces that ordering deterministically, and it fails without the client change. - fully static pages keep the inline bootstrap and hydrate It fails on `canary` because the bootstrap is in the shell without a nonce and the page doesn't hydrate. Existing suites run to check behavior didn't change: - Turbopack start: `instant-navigation-testing-api` (this suite caught the late-bootstrap `Invalid URL` issue), `ppr-partial-hydration`, `partial-fallback-root-blocking`, `partial-fallback-shell-upgrade`, `csp-nonce-segment-scripts`, `next-dynamic-csp-nonce`, `static-shell-debugging` - Webpack start: `csp-nonce-segment-scripts` - Dev (Turbopack): `csp-nonce-segment-scripts` I also checked by hand with the issue's reproduction (nonce CSP from `proxy.ts`): the page hydrates and only the `$RT` violation remains. Not run: Vercel deploy and edge-runtime tests. Fixes #99800 <!-- NEXT_JS_LLM --> <!-- fleet 551793ce-4e56-41fa-ab7b-183f9c45ac27 --> --------- 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>
-
Tobias Koppers authored
### What? Requests that pass through middleware / `proxy.ts` now produce **one OpenTelemetry trace**, instead of two or three. Before, with OTEL configured in `instrumentation.ts`: | Request | No outer span | With an outer span (APM, custom server) | |---|---|---| | Middleware continues to render (`next()` / rewrite) | 3 traces (2 before 16.3) | 2 traces (1 before 16.3) | | Middleware redirect / direct response | 2 traces (1 before 16.3) | 2 traces (1 before 16.3) | After: 1 trace in every case. ### Why? Two independent causes: 1. **Long-standing (13.5 → canary), #91282.** When middleware lets a request continue, the router server runs `BaseServer.handleRequest` twice: a middleware-invoke pass, then a render pass. Each pass extracts its context from the incoming request headers. Without an incoming `traceparent`, each pass started its own root trace. 2. **16.3 regression from #95306.** In-process Node.js middleware ran under `ROOT_CONTEXT` to make `Middleware.execute` a sibling of `handleRequest`. That also detached it from any outer span, so the middleware span always started an extra trace. Customers upgrading 16.2 → 16.3 see this as "doubled traces". ### How? When middleware lets a request continue, the render is always **nested inside the middleware span**, in every host: ``` next start / next dev: handleRequest GET (bubble, root) └─ middleware GET └─ GET /page separately-invoked middleware (Vercel, adapters, direct entrypoints), no parent: middleware GET (root) └─ GET /page host span / incoming traceparent P: P └─ middleware GET (next start: P → handleRequest GET → middleware GET) └─ GET /page ``` **Middleware → render.** The middleware adapter forwards the `Middleware.execute` span's own W3C context (`traceparent` / `tracestate`, via the configured propagator) as request-header overrides on `next()` and rewrite responses. Every host already applies these overrides to the downstream request, including the `next start` router server, so no new host protocol is needed. - Override lists replace the whole downstream header set. So: - **No user overrides:** the adapter lists every request header the middleware received, plus the trace headers. - **User overrides present:** they are kept, and the trace headers are added. - **User-set trace headers:** a `traceparent` / `tracestate` the middleware explicitly set (different from the one it received) wins. A value copied unchanged from the request, as with `new Headers(request.headers)`, is replaced so the render still nests. - Redirects and direct responses are untouched. **Request → middleware (self-hosted).** Once the middleware-invoke pass's `handleRequest` span is active, its W3C context is written onto the request headers. The middleware adapter (Node.js and the Edge sandbox) extracts it, so the middleware span is a child of that pass. The middleware-pass span keeps its existing name (`GET`); the route stays on the render-pass span. If there is no middleware span to forward (for example OTEL is registered only for Node.js while middleware runs on Edge), the render falls back to this context and still stays in one trace. **#95306 regression.** The `ROOT_CONTEXT` detachment is removed, so an outer span, an incoming `traceparent`, or the middleware-pass span now parents Node.js middleware normally. All of this only runs when OpenTelemetry is active and a valid span context exists. Without OTEL, no headers are added. One-time initialization traces stay separate by design: instrumentation registration, route-module prewarming, and the once-per-process lazy `RouteModule.prepare` of direct entrypoints. ### Tests - **New deploy-capable suite `test/e2e/app-dir/otel-middleware-single-trace`.** It runs Node.js `proxy.ts` and Edge `middleware.ts` with `@vercel/otel`. Middleware reports its active trace and span IDs; the render reports its active trace ID and the `traceparent` it received. The test asserts one trace and that the render's parent is the middleware span, so no collector is needed. It runs in dev, start and deploy mode, with no deploy gate. It covers: - continue to a page and to a route handler, plus rewrite, redirect and a direct response; - a request the middleware doesn't match, and an incoming `traceparent`; - user header overrides, including a deletion (the render still nests), and a user-set `traceparent`; - no internal `x-middleware-*` headers reaching the client. - **Existing collector suite `test/e2e/opentelemetry/instrumentation`.** The middleware tests now assert **real** trace IDs and the exact shape: the render span's parent is the middleware span, the middleware span's parent is the middleware-pass `handleRequest` (self-hosted) or the external / host parent. They also check every span exported for the request. - **Setups:** default and direct-entrypoint hosting; Edge and Node.js middleware; root context and incoming `traceparent`. - **Requests:** page, route handler, rewrite and redirect. - **New variant:** direct entrypoints with a host parent span. - **Unit tests** for the override helper (`forward-trace-context.test.ts`), including unchanged copied trace headers. ### Verification - The new suite's nesting checks and the collector shape checks fail before this change (render parented to `handleRequest` or the external span) and pass after it. - New suite passes in dev (Turbopack), start (Turbopack, webpack), and the same with `__NEXT_CACHE_COMPONENTS=true`. - Full `test/e2e/opentelemetry/instrumentation/` passes in start mode (Turbopack); the middleware tests also pass in dev (Turbopack) and start (webpack). - Passed on the previous revision (not re-run for the nesting change): `test/e2e/opentelemetry/client-trace-metadata`, `test/e2e/app-dir/otel-parent-span-propagation`, `test/e2e/middleware-request-header-overrides`, and the W3C trace-header fetch-cache test in `test/e2e/app-dir/app-static`. - Deploy: an earlier revision's trace-ID assertions passed on Vercel (default and Cache Components). The new parent-span assertion runs on Vercel for the first time in this revision's CI. Fixes #91282 <!-- NEXT_JS_LLM --> <!-- fleet ce0ecb23-b14c-4679-92a9-e676130f618e --> --------- 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> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
-
Tobias Koppers authored
### What? In webpack dev, manifest files (`*manifest.json` / `*manifest.js`, e.g. `next-font-manifest.json` and `page_client-reference-manifest.js`) are now written atomically: the content goes to a temp file next to the manifest, which is then renamed over it. Other emitted assets are written as before. ### Why? This fixes a canary hard flake in `test/e2e/app-dir/not-found/basic` › "should render the 404 page when the file is removed, and restore the page when re-added" ([example](https://github.com/vercel/next.js/actions/runs/38003705301/job/114068060547)). It is a real dev-server bug: - Renaming `app/page.js` away makes `/` render `/_not-found`. That entry is already built, so the render doesn't wait for the in-flight rebuild. - Webpack writes emitted assets in place (it truncates first). `RouteModule.loadManifests` can therefore read a 0-byte manifest. Instrumented local runs caught `.next/dev/server/app/_not-found/page_client-reference-manifest.js` (`Manifest file is empty`) and `.next/dev/server/next-font-manifest.json` (`Unexpected end of JSON input`). CI shows the same errors on every retry. - The request returns a 500, the browser lands on the pages error page, which never recovers through app-dir HMR, and the test times out after 120 s. Turbopack already writes its manifests with `writeFileAtomic` and isn't affected. ### How? - `createAtomicManifestOutputFileSystem(fs)` returns an output FS that inherits from webpack's shared `graceful-fs` object without mutating it. Manifest writes go through the existing sync `writeFileAtomic` helper (`lib/fs/write-atomic.ts`, now accepting `Buffer`). That helper is the same one Turbopack's manifests use, and it already handles temp naming, cleanup and the Windows-tolerant `renameSync`. All other writes and methods go to the original FS. - One wrapped FS is created next to the shared `inputFileSystem` and assigned to every compiler in the multi-compiler. The fallback compiler is wrapped too. - This assumes the disk-backed dev output that Next.js uses. The dev server reads these manifests from disk with Node `fs` anyway. ### Verification Full test file, `pnpm test-dev-webpack`, CI env (`NEXT_TEST_REACT_VERSION=18.3.1`, `__NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true`): | | Runs | Manifest read errors | Failures | |---|---|---|---| | canary | 8 | 5 | 5 | | this PR | 10 | 0 | 2* | \* Both remaining failures happened at the *restore* step: an HMR refresh arrived before the app router initialized. That's a separate root cause, fixed independently in #100113, and with both PRs applied the file passed 10/10. - `pnpm test-dev-turbo`: 3/3 passed. `pnpm test-start-webpack`: passed. - After the switch to `writeFileAtomic`, with #100113's fix applied: 5/5 full-file `pnpm test-dev-webpack` runs passed in the same CI env, with no manifest read errors. - Unit tests run against a real temp dir. They cover Buffer bytes being preserved and the target keeping its complete old content at the rename boundary (then the complete new one). They also cover errors reaching the callback exactly once, no leftover temp files, delegation of non-manifest writes, and the original FS not being mutated. <!-- NEXT_JS_LLM --> <!-- fleet e9d6c475-aeff-42d9-a058-210b6631f951 --> --------- 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> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
-
- 14 Oct, 2026 10 commits
-
-
Benjamin Woodruff authored
Apparently turborepo adds this now it if detects it is being run inside of an agent harness. https://turborepo.dev/docs/guides/ai#version-matched-agent-guidance Commit this so that it stops showing up as changes in my working tree.
-
next-js-bot[bot] authored
-
Benjamin Woodruff authored
[`RawValue::from_string`](https://docs.rs/serde_json/latest/serde_json/value/struct.RawValue.html#method.from_string) attempts to deserialize values to ensure they're valid JSON. The original version of this PR used [`RawValue::from_string_unchecked`](https://docs.rs/serde_json/latest/serde_json/value/struct.RawValue.html#method.from_string_unchecked), which introduced some `unsafe` usage to avoid the parse. Luke's comments revealed some better approaches. For `pages_chunk_group_bootstrap_params`, we're also able to avoid a string copy by using `RcJsonRawValue` and serializing a `&RawValue` instead of a `Box<RawValue>`.
-
kxrn_gupta authored
### Description - Fixed minor typo ('This example show' -> 'This example shows') in `with-passport` README. - Updated outdated HTTP URLs to HTTPS for Passport.js and Upstash across example READMEs. -
Joseph authored
Fixes #100173
-
Tobias Koppers authored
## Summary On macOS, frequent writes to an untracked file kept the watcher batch open and delayed the invalidation of tracked files until the writes stopped. This made the native cases of `irrelevant_events_do_not_delay_invalidation` fail consistently (took ~3.3s, i.e. the whole churn). Why: FSEvents keeps the `ItemCreated` flag set on a recently created file, so each write to an existing file shows up as a `Create(File)` event. When a tracked file in the same directory changed, `mark_parent_dir` added that directory to the batch, even though nothing had listed it. The fast path in `is_relevant` then treated every later `Create` of a sibling as relevant because its parent was in the batch, and each of those events pushed the batch deadline back. The fast path now only checks the path itself. The slow path still checks the parent against `dir_invalidator_map`, so events under a directory whose listing is tracked still count as relevant. ## Verification - `cargo test -p turbo-tasks-fs --lib watcher::` on macOS: all 19 tests pass, including `repeated_writes_to_tracked_file_are_debounced`. Before this change, the two native `irrelevant_events_do_not_delay_invalidation` cases failed.
🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- NEXT_JS_LLM --> --------- Co-authored-by:Benjamin Woodruff <benjamin.woodruff@vercel.com>
-
Luke Sandberg authored
A new log message added in the most recent react 19 update doesn't exist when we run react 18, just disable the test
-
Aurora Scharff authored
## Summary Document that `eslint-config-next@16.4.0` and later supports ESLint 10 with the default React version detection, so users can remove a `settings.react.version` override added for the `context.getFilename` error. Align the Next.js 16 upgrade guide with the ESLint 9 minimum and the ESLint 10 support boundary. Finding: https://next-maintainer-agent.vercel.tools/agent-feedback/1854 ## Verification - `prettier --check docs/01-app/03-api-reference/05-config/03-eslint.mdx docs/01-app/02-guides/upgrading/version-16.mdx` - `git diff --check` - `alex docs/01-app/03-api-reference/05-config/03-eslint.mdx docs/01-app/02-guides/upgrading/version-16.mdx --quiet` (reported only pre-existing warnings outside the changed lines) - Not run: `pnpm lint` (docs-only change; targeted formatting and prose checks run) <!-- NEXT_JS_LLM -->
-
Benjamin Woodruff authored
Hopefully this should make test setup a little faster and it should make it easier for me to test compatibility with pnpm GVS (#99758). I previously tried to upgrade us to pnpm 11, but couldn't because it requires Node 22+, and we need to test against Node 20. However, pnpm 12 is written in Rust, and does not depend on particular versions of Node. ## Other notable changes - Nx: Some of our tests needed an upgrade. It parses the pnpm lockfile, like Turborepo. - pnpm 12 fails to install from an uncompressed tarball (only supports gziped-tarballs?), so this builds the `tgz` from source (previously we had a binary tarball committed to the repo). ## Testing I manually ran the e2e deployment tests: https://github.com/vercel/next.js/actions/runs/38491349790
-
Aurora Scharff authored
## Summary Reverts the combined Next.js changes from #100126 and #100189 by removing the release-eval dispatcher. Release discovery and execution will live entirely in `vercel/next-evals-oss`, avoiding a cross-repository reusable-workflow pin in Next.js. ## Verification - Not run (workflow deletion only) <!-- NEXT_JS_LLM -->
-