- 07 Aug, 2026 4 commits
-
-
next-js-bot[bot] authored
-
Andrew Clark authored
The previous PR in this stack introduced TransportData, the unified response format, but produced it via a temporary adapter layer that converted from the old data formats — FlightRouterState and CacheNodeSeedData trees, encoded as FlightDataPath entries. As promised there, this PR updates the server to produce the new format directly and deletes the adapter. Neither FlightRouterState nor CacheNodeSeedData appears in a rendered response anymore; FlightRouterState survives only on the client (router state, history) and as the request tree the client sends to the server, and CacheNodeSeedData is deleted from the codebase entirely. createComponentTree now returns the response's transport tree: each node carries its segment identity, its prefetch hints, and its render output, constructed in place as the tree renders. When a non-PPR prefetch stops at a loading boundary, the subtree below the cut is emitted as structure-only nodes with no render output — the same shape the client already interprets as "fetch lazily". createFlightRouterStateFromLoaderTree is replaced by createTransportTreeFromLoaderTree, which covers the cases where nothing is rendered: router-state-only responses, route tree prefetches, the structure below a loading-boundary cut, and error payloads. The prefetch hints computation is shared with createComponentTree through computeSegmentPrefetchHints so the two producers cannot drift. walkTreeWithFlightRouterState returns the transport tree those producers build: each emit is a transport node, and the levels above it become "skipped" nodes (position acknowledged, no output attached). The FlightDataPath encoding this replaces — repeating [segment, parallelRouteKey] prefixes terminated by a positional data tuple, plus the hack in generateDynamicRSCPayload that sliced the root segment off every path — is deleted, along with the FlightData, FlightDataPath, and FlightDataSegment types. This also deletes the overriddenSegment / canSegmentBeOverridden mechanism, which turned out to be dead code: it could only trigger if a dynamic segment reached the walk as an uninterpolated string, but getDynamicParam throws in that case rather than returning null. Instant validation rebuilds its payload tree natively as well: the builders walk the original payload's transport tree in parallel with the loader tree, taking structure from the former and render output from the validation segment cache.
-
Andrew Clark authored
Introduces a new type, TransportData, to replace FlightDataPath. The new format is the same regardless of whether the entire page is rendered by the server or if some segments are intentionally omitted. The type also unifies FlightRouterState and CacheNodeSeedData into a single tree that includes both route information and RSC data. Previously these were sent in two separate trees that were isomorphic by convention, requiring the consumer to walk both in parallel. These new types are intended to be transport formats only. The client already has its own, richer data structure called RouteTree. The transport format is converted into the client format at the network decoding boundary. This does not remove FlightRouterState from the codebase entirely; it's still used both for issuing requests to the server (Next-Router-State-Tree) and for tracking state in the browser's history object. A future refactor may replace it for the purpose of issuing requests, but it will likely survive as the format for tracking state in history. This PR does not yet update the server to produce TransportData directly; a temporary adapter layer is used to convert from the old data formats to the new format. This intermediate step will not land on its own; the next PR in the stack will both update the server and delete the temporary adapter layer.
-
Andrew Clark authored
The client used to represent a server response as two parallel trees: a RouteTree describing the route structure, and a CacheNodeSeedData tree carrying the rendered output for each segment. The two are meant to be isomorphic, but nothing enforced that — every consumer walked them in lockstep and had to defend against mismatches between them. This PR adds a `data` field to the RouteTree type and makes it generic over a per-segment payload. For a server response, the type is RouteTree<RSCSegmentData | null>. This removes the need to pass a separate CacheNodeSeedData through the client navigation algorithm in ppr-navigations.ts. This is a step toward replacing the RSC response transport format: with the client consuming a single unified tree, the wire format can move to one as well.
-
- 06 Aug, 2026 9 commits
-
-
Will Binns-Smith authored
### What? Replace `DetachedPromise` with the shared `createPromiseWithResolvers` helper and use that helper in the vendored `@mswjs/interceptors` Node 20 shim. This can go away entirely when we support Node 22 at minimum. ### Why? Next.js maintained duplicate deferred-promise implementations in `src/lib/detached-promise.ts`, `src/shared/lib/promise-with-resolvers.ts`, and the interceptor bundle entry. ### How? - Migrate `DetachedPromise` consumers to `createPromiseWithResolvers` - Delete the duplicate `DetachedPromise` implementation - Delegate the interceptor's required global polyfill to the shared helper - Update the generated interceptor bundle and server trace snapshot Validated with `pnpm --filter=next types`, focused Jest tests, ESLint, Prettier, and the `ncc_mswjs_interceptors` bundle task. <!-- NEXT_JS_LLM --> --------- Co-authored-by:
Sebastian "Sebbie" Silbermann <sebastian.silbermann@vercel.com> Co-authored-by:
vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
-
Sebastian "Sebbie" Silbermann authored
Gets rid of of all usages of the static `GH_TOKEN_PULL_REQUESTS` token that was issued for `vercel-release-bot`. We already create commits with `nextjs-bot`. `nextjs-bot` already had permissions to open PRs which is already being used by React sync.
-
Zack Tanner authored
## Summary The Instant Navigation testing API is only supported with Cache Components, but its testing cookie could previously force a non-Cache Components route into the legacy PPR rendering path. This can cause requests to fail because that path relies on React’s deprecated `unstable_postpone` API, which is unavailable in the stable React runtime. This change couples testing API exposure and its client bundle machinery to Cache Components, removes the testing-only PPR capability override, and adds regression coverage confirming that the API remains inactive without Cache Components. Supported Instant Navigation behavior is unchanged.
-
dan authored
In dev, `"use cache"` entries are keyed by an HMR refresh hash so that edits invalidate cached data. This hash was managed wrong in both directions: - webpack refreshed the hash at moments when no code changed: on dev server startup, and when a page file was added or removed. Each refresh threw away all cached data for nothing. - The hash never distinguished one dev server run from another. That matters with a custom cache handler that persists entries: a restarted server would serve data cached by the previous run, whose code may have changed while the server was down. To fix this: - Adding or removing a page no longer refreshes webpack's hash. Edits and env file changes still do. - The hash now includes a random per-run value. This fixes the `cache-components-dev-warmup` flakes. ## How to reproduce Here's the first problem in action, on webpack. Render a cached `Math.random()` on a page, then create an unrelated page file: ``` value: 0.199426 value: 0.199426 $ echo '...' > app/unrelated/page.tsx # never visited value: 0.990973 # cached entry gone a second later ``` Adding the page threw the cached data away. Starting the dev server throws it away too, once, shortly after boot. That one is a race: normally the cache is still empty when it fires, so nobody notices — but if the first page request gets in before it, everything that request cached is thrown away and the next reload is silently cold. That race is the cause of the `dev-warmup` flakes on loaded machines, and it's how I found this. The hash refresh is specific to webpack, so Turbopack doesn't lose cached data this way. On Turbopack, these events instead clear the server's module cache. Whether the next render picks up a fresh module instance is a race, so module-scope state can reset. Turbopack also has a separate bug in this area — it advances its hash once per change-subscription emission, and an added or removed page can produce an emission without any edit — which #96248, stacked on this PR, fixes by deriving the hash from compiled output. ## Underlying cause Next computes a "client router filter" (a bloom filter over the app's routes, used by the client-side router), and a filter change is treated like an env file change. An env change means cached data might be stale, so the reaction is strong: the browser is told to re-fetch, and on webpack the hash is refreshed, which discards every cached entry. But the filter is derived from the routes, so it "changes" whenever you add or remove a page — and once right after startup, because the first computation has nothing to compare against. Neither makes cached data stale. The second problem is the opposite: dev server runs share cache keys. The hash starts from the same value on every run (unset on webpack, `"0"` on Turbopack), so a restarted server generates the same keys as the old one. With the default in-memory handler that's moot, but a custom cache handler that persists entries will serve entries written by the previous run. webpack can also hit this after edits: its hash is derived from compiled output, so re-applying an edit that a previous run also made lands on that run's keys. Judging by the code (?), dev cache reuse was only ever meant to last a single run: every dev cache mechanism is in-memory, and #75474 takes it for granted that restarting the dev server clears cached content. So I treat cross-run reuse as a bug. Not sure I got this constraint right — in particular, #75474 deliberately made reverting an edit reuse previously cached data, and this PR keeps that working within a run but stops it from working across runs. ## Fix Two changes: - A filter change is no longer treated as an env change. It still updates the compiled-in filter value (the part that's actually needed), but it no longer refreshes the hash, and on Turbopack it no longer wipes the server's module cache. Real env file changes still trigger the full reaction. - The hash now starts from a random per-run value on both bundlers. So it exists before the first request and never matches another run's keys. The per-run value is deliberately conservative: it also prevents reuse across restarts where *nothing* changed. Allowing exactly that reuse safely needs keys derived from the cached function's implementation (the existing TODO in `use-cache-wrapper.ts`), which would replace the per-run value. ## Test plan The first commit adds five tests (`test/development/app-dir/cache-components-spurious-cache-invalidation`). They run on both bundlers, except the module-state test, which is Turbopack-only: on webpack, adding a page recompiles the server bundle, which replaces the module instances regardless. So Turbopack runs five and webpack four. Before the fix, these fail: ``` webpack: ✕ discards use cache entries when a previous run made the same edit ✕ discards use cache entries across dev server restarts (most runs — see below) Turbopack: ✕ keeps module state when an unrelated page is added ✕ discards use cache entries across dev server restarts ``` The webpack restart test does not fail every run. The start-time refresh replaces the unset hash with a content-derived one at an unpredictable moment. When one server run caches before its refresh and the other reads after its own, the keys don't collide, so there is no cross-run reuse for the test to catch that run. The webpack side of the over-invalidation fix is covered by the refetch count below rather than by a cached-value test: the equivalent test on Turbopack depends on emission timing, so it lands with #96248, which removes that dependence. The same commit also tightens the refetch count in the test from #96250 below: since a page add is no longer an env change, adding a page refetches an open tab once instead of twice, on both bundlers. Before the fix, both bundlers fail that expectation (`Expected: 1, Received: 2`). To reproduce the flake this PR fixes, run the dev-warmup suites under CPU load (`for i in $(seq 1 12); do yes > /dev/null & done`). Before the fix, 6–8 of the 11 tests fail per run on webpack (`Prerender` flips to `Server` on warm reloads). After the fix, all 11 pass. Turbopack passes before and after. Also still green: `typed-env` (env definitions were previously only written at boot via the false positive this removes; now they're written on the initial scan explicitly), `env-config`, `use-cache-custom-handler`, and `pages-to-app-routing` (it exercises the router filter update path). -
dan authored
The dev server tells open tabs when a page is added or removed, so a tab showing a 404 picks up a page you just created, and a tab showing a page you just deleted falls back to the 404. Both bundlers computed the list of changed pages wrong, in opposite directions. **Turbopack announced pages that hadn't changed.** To find what changed, it compared the new route list against the entry maps in `currentEntrypoints`. Those maps key App Router entries by page name (`/blog/page`), but the route list is keyed by route (`/blog`), so no App Router route ever matched: every update announced every existing app route as added and every page name as removed, and starting the server announced every route once. Each announcement makes every connected tab refetch. Fixed by comparing the new route list to the previous route list, which uses the same naming. Starting the server now announces nothing on either bundler, since the first route list is not a change. **webpack didn't announce pages that had changed.** It only announced when `prevSortedRoutes.every((val, idx) => val === sortedRoutes[idx])` was false. That is a prefix comparison: when a new route sorts after all existing ones, the old list is a prefix of the new one, and nothing is announced. In App Router this mostly went unnoticed, because adding a page was also (wrongly) treated as an env change, which refreshed tabs anyway; the next PR in this stack removes that. In Pages Router nothing hid it: the route manifest was never refetched, so client-side navigation to the new page kept returning 404 until a manual reload. Fixed by also comparing the lengths. **What this PR does not fix:** on Turbopack there is a window right after a page is added where the dev server has already announced it to tabs, but can't serve it yet (the route isn't in the dev router's route table until the watcher pass in `setup-dev-bundler` runs). A tab that reacts inside that window gets the 404 again, and since each page is only announced once, it stays on the 404 until you reload it by hand. That bug predates this PR and is being fixed separately. So that the new App Router tests don't hit this window, each one edits the added page again once it's confirmed servable. The edit makes the server announce again, and this time the tab can only get the page. The trade-off is that these tests don't prove the first announcement alone updates the tab — the refetch-count test covers how often changes are announced, and its tab never sits on the added page's 404, so it can't hit the window. A TODO in the tests says to drop the extra edits once the underlying bug is fixed. The Pages Router test needs no such edit: Turbopack updates the route matchers before it announces, and a Pages Router tab reloads the document instead of refetching. ## Test plan New tests cover adds, removals, dynamic routes, route groups, and a dynamic route being shadowed by a more specific page and then unshadowed. One more counts how often an open tab refetches when a page is added: it wraps the tab's `fetch` and counts requests carrying the `next-hmr-refresh` header, which distinguishes a refetch the dev server asked for from a navigation or a prefetch. It runs on a dev server no other test shares, because the count depends on what has been compiled so far. Before the fix, adding one page makes an open tab refetch: ``` Turbopack: 12 times (every app route re-announced; grows with the number of routes) webpack: 1 time (the announcement is never sent; only the env-change refetch happens) ``` The correct count is currently 2: one refetch for the announcement, one for the env-change false alarm. The next PR removes the false alarm and tightens the expectation to 1. Before the fix, webpack also fails the Pages Router manifest test (the manifest update is sent from the same skipped branch). With the fix, both bundlers pass all ten tests.
-
Rich Haines authored
## What Updates docs links whose targets have moved. Found by an automated docs link audit: every old URL below currently serves a `308` (permanent redirect), so readers take an extra hop and the links rot as redirect maps are pruned. Each replacement is the **final `200` URL** of the redirect chain (verified with `curl -sIL`), not just the first hop. Only the path component was rewritten — scheme, host, query strings (`?utm_source=...`) and fragments are untouched. | Old path | Now points at | | --- | --- | | `vercel.com/docs/concepts/functions/edge-functions/og-image-generation` | `/docs/og-image-generation` | | `vercel.com/docs/frameworks/nextjs` | `/docs/frameworks/full-stack/nextjs` | | `vercel.com/docs/observability/otel-overview` | `/docs/tracing/instrumentation` | | `vercel.com/docs/concepts/observability/otel-overview/quickstart` | `/docs/tracing/instrumentation` | | `vercel.com/docs/edge-config/get-started` | `/docs/global-config/get-started` | | `vercel.com/docs/functions/vercel-functions-package` | `/docs/functions/functions-api-reference/vercel-functions-package` | | `vercel.com/docs/edge-network/overview` | `/docs/cdn` | | `vercel.com/docs/storage/vercel-blob` (×4) | `/docs/vercel-blob` | | `vercel.com/docs/storage/vercel-blob/server-upload` | `/docs/vercel-blob/server-upload` | | `vercel.com/docs/storage/vercel-blob/client-upload` | `/docs/vercel-blob/client-upload` | | `vercel.com/docs/concepts/image-optimization` | `/docs/image-optimization` | | `nextjs.org/docs/app/building-your-application/rendering` | `/docs/app/getting-started/caching` | The four Pages Router pages flagged by the audit (`deploying`, `guides/instrumentation`, `guides/open-telemetry`, `guides/redirecting`) share their source with the App Router versions via frontmatter `source:`, so fixing the App Router files covers them. ## One link worth a reviewer's eye In `use-client.mdx`, the client-server **boundary** link pointed at `/docs/app/building-your-application/rendering#network-boundary`. That path 308s to `/docs/app/getting-started/caching`, which is what this PR uses — but the redirect target is topically unrelated to the client-server boundary, and no `#network-boundary` heading exists on it (or anywhere else in `docs/`). If you'd prefer, `/docs/app/getting-started/server-and-client-components` is the closer page and I'm happy to switch it (the anchor would have to be dropped either way). ## Also checked: `viewTransition` The `next-config-js` reference index on nextjs.org still lists an entry linking to `/docs/app/api-reference/config/next-config-js/viewTransition`, which 404s. No change is needed in this repo: that page was intentionally deleted in 28a9465d ("docs: view transitions guide — skill section, source-audit fixes, flag-removal docs", #96097) as the docs half of the `experimental.viewTransition` flag removal (#96098), and the guide now states that view transitions work with no configuration. There is no surviving config option to repoint at, and no link to it remains anywhere in `docs/` or `packages/*/src` on `main` — the stale index entry comes from the nextjs.org versioned (v15) nav manifest, outside this repo. ## Verification - `prettier --check` passes on all changed files. - `alex` (`lint-language`) reports only pre-existing prose warnings on untouched lines. - No `next.js` build was run; this is a docs-only, path-only change. ▲ Created with [Vercel devbox](https://vercel.com/vercel/~/sandboxes/devboxes/1us5zdxyl2nk5ccodexgd9w3f6k2) --------- Co-authored-by:
Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by:
Joseph <sephxd1234@gmail.com> Co-authored-by:
vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
-
kyamaz99 authored
### What? Start a next application after 16.2.0 in a safari 9 which is used in playstation 4. The application will error with this message ```TypeError: Unable to delete property``` ### Why? We narrow down the problem to this line ```delete document.documentElement.dataset.dplId ``` in ```packages/next/src/shared/lib/deployment-id.ts ``` It seems to be related of how webkit implemented dataset, as discussed in this [thread](https://stackoverflow.com/questions/28973603/unable-to-delete-property-on-safari-when-trying-to-delete-dataset-attribute-in) ### How? replace this line ``` delete document.documentElement.dataset.dplId; ``` with ``` document.documentElement.removeAttribute('data-dpl-id');``` if data cannot be deleted , we can remove the attribute. It should achieve the same with a different syntax Fixes #94601
-
Sebastian "Sebbie" Silbermann authored
-
Niklas Mischkulnig authored
https://github.com/vercel/next.js/issues/94634#issuecomment-5190067214: > Module not found: Can't resolve '@swc/helpers/_/_wrap_reg_exp' > This is on 16.3.0, if that matters. I'm not sure if I understood you completely, but I want to try your fix before I open a new issue. That helper was added in March 2026. We had upgraded the swc crates itself but never upgraded the swc helpers.
-
- 05 Aug, 2026 27 commits
-
-
Sam Poder authored
This test keeps tripping up my agent up and the test was failing because we print a helpful warning message. We can actually run this test.
-
next-js-bot[bot] authored
-
dan authored
## Summary Harness fixes, all surfaced while benching a Fizz-only React PR (react/react#37022): - **Profile pass now alternates arm order by VM index.** The timed runs are ABBA, but the CPU profile pass ran base-then-cand on every VM. The second arm runs warmer (page cache, governor), which deflated every function in the cand profile by a uniform few percent — untouched Flight frames "improved" ~7%. With balanced order the same untouched frames diff to ~1.5% across 14 paired VMs while real movers keep their magnitude. Each VM records its capture order in the profiles tarball (`prof-order.txt`) so analyses can check order drift directly. - **The fingerprint now covers every server-side React layer.** `FP_FILES` hashed only the vendored Flight server files, which a Fizz-only React change leaves byte-identical — both arms of a valid A/B reported the same fingerprint. Added the vendored Fizz bundle and the shared react-server runtime (hooks/cache) in both suites. The VM boot loop also warns loudly when arms fingerprint identically, instead of leaving it for the analysis footer. - **`--prepare` writes a terminal status phase.** It previously exited leaving `phase: "measuring"`, so `bench-status` prescribed collecting measurement data that never existed. `bench-status` now reports prepare-only runs as complete rather than "DEAD — relaunch". ## Verification - Full 16-VM e2e run with the ordering + Fizz-fingerprint changes (`run-pr37022-e2e-prof2`): arms fingerprint distinctly (`18ea275e` vs `f9805be5`), profile order alternates per VM, untouched hot frames diff to ~zero in the cross-VM profile aggregate. - `bench-status.mjs` against a real `--prepare` run dir reports `complete (--prepare: caches only)`. - `--dry-run` smoke of the modified launcher; `node --check` on all three scripts. <!-- NEXT_JS_LLM -->
-
Zack Tanner authored
## Summary Foreground revalidation is necessary when a stale result will be persisted by another server cache, not only when the request is prerendering. Otherwise, a cache created during a dynamic request can consume a stale inner value and extend its lifetime. - derive foreground revalidation from whether the immediate work-unit consumer will persist the result in a server cache - model that capability as willConsumerServerCache rather than inheriting it through the full outer scope chain - treat server cache and static prerender work units as server-caching consumers, while runtime prerenders are not - add regression coverage for an outer "use cache" scope consuming a stale unstable_cache entry <!-- NEXT_JS_LLM -->
-
Sam Poder authored
Closes https://github.com/vercel/next.js/issues/96648, take a look at code like this: <img width="1414" height="1336" alt="image" src="https://github.com/user-attachments/assets/7195f963-51a9-4331-be74-3e06be760422" /> Line 26 of scope-hoisting group A enters scope-hoisting group B, then on line 95 we re-enter scope-hoisting group A. Because our first execution of group A hadn't reached Line 29 yet to register schemas.js (which B depends on schemas.js). On non-scope hoisted modules with cycles we already raise the module registration call to the start of the factory. But when we scope hoist, we lose that. This PR changes it so we do the registration at the start of the scope hoisted module Before: ```javascript "shared.js", "library/src/schemas.js", "library/src/index.js <export * as z>", ((__turbopack_context__) => { "use strict"; // MERGED MODULE: shared.js ; var …errors = __turbopack_context__.i("library/src/errors.js"); // MERGED MODULE: library/src/index.js <export * as z> ; // MERGED MODULE: library/src/index.js ; var …index_locals = __turbopack_context__.i("library/src/index.js <locals>"); // ← leaves the group // MERGED MODULE: library/src/schemas.js ; __turbopack_context__.s([ // ← schemas registers HERE, too late "any", ()=>any, "anyBase", ()=>anyBase, "instance", ()=>instance, "instanceFromClosure", ()=>instanceFromClosure ], "library/src/schemas.js"); var …iso = __turbopack_context__.i("library/src/iso.js"); ``` After: ```javascript "shared.js", "library/src/schemas.js", "library/src/index.js <export * as z>", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ // ← raised to the top of the merged module "any", ()=>any, "anyBase", ()=>anyBase, "instance", ()=>instance, "instanceFromClosure", ()=>instanceFromClosure ], "library/src/schemas.js"); // MERGED MODULE: shared.js ; var …errors = __turbopack_context__.i("library/src/errors.js"); // MERGED MODULE: library/src/index.js <export * as z> ; // MERGED MODULE: library/src/index.js ; var …index_locals = __turbopack_context__.i("library/src/index.js <locals>"); // ← re-entry is safe // MERGED MODULE: library/src/schemas.js ; var …iso = __turbopack_context__.i("library/src/iso.js"); ```
-
dan authored
Relands #95682 (reverted in #95853 due to #95848). This contains: - A bunch of tests (some failing and some passing before this PR; all passing after this PR). - The fix from #95682. In short, we use Navigation API to detect during hydration that we're on a different history entry than we started, and in that case, replay the missed traversal with similar logic to what we do for `onPopState`. The issue with the original PR was that under Activity, React would sometimes hang applying the state update. This was fixed in https://github.com/react/react/pull/37135 and synced, so we can do this fix again now. ## Test Plan Old and new tests.
-
Aurora Scharff authored
Each Skill section was a prose paragraph that assumed you had read the ones above it. Reframe the three shipped Skills as a lead sentence, three steps, and a linked prerequisite, so landing on an anchor from search is enough. Also drops the claim that the optimizer makes a route instant. It works one navigation toward the UI you decide should be there, and commits the passing test with the refactoring. <!-- 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 We encourage you to use AI to assist you in researching, creating, and reviewing changes. However, you must review and deeply understand the contributions you are making. For this reason, **pull request descriptions from external contributors must be written by a human**. ### 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 ### 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 ### Signed commits - This repository requires verified commit signatures on protected branches. - If this pull request is blocked for unsigned commits, re-sign the commits and force-push the branch. - A `Signed-off-by` line in the commit message is not enough. ## 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 # --> Co-authored-by:
Claude Opus 5 <noreply@anthropic.com>
-
Hendrik Liebau authored
Calling the same `'use cache: private'` function twice in one request executed its body twice in production. Preloading at the top of a segment and reading the same function again lower down for composability, which is the shape that motivates a preload in the first place, therefore did the work twice instead of once. The intra-request dedupe map dropped an entry as soon as its fill completed, so it only ever covered concurrent invocations. A later invocation fell through to the cache handler, and the `React.cache` memo wrapping every cache function missed whenever the arguments were not reference-equal. Public caches got a handler hit out of that, but private caches have no handler in production and their entries are excluded from the immutable Resume Data Cache of a dynamic request, so nothing had stored the entry. Completed invocations now move into `completedCacheInvocations` on the work store instead of being dropped, and a later invocation joins that entry. The pending map keeps its previous semantics untouched, because a concurrent joiner shares a fill that is genuinely in flight and must not re-run the discard checks against it, whereas a completed entry is a stored value and is only reused when the caller has not asked to bypass caches and nothing has invalidated it since. Private caches still get no cache handler, so the map is what backs them, and it lives on the work store and so cannot carry request-derived data beyond the request that produced it. Retention is limited to the kinds where it saves real work: private caches, and kinds whose handler came from the platform or from `cacheHandlers` config, where a read can be a network round trip. `isBuiltInCacheHandler` answers that by tracking the handler instances `initializeCacheHandlers` constructs itself. Recording instances rather than kinds is what keeps aliasing right, since a self-hosted `remote` resolves to the very same in-memory handler as `default` and retaining its entries would duplicate that cache for nothing, while a platform-supplied `remote` does not. The `use-cache-custom-handler` suite covers the mechanism rather than the observable value, counting `::get` calls to assert that two sequential reads reach the handler once. Value equality alone cannot distinguish a retained entry from a handler hit, which is also why the new `dedup-sequential` fixture passes without this change and serves only as a regression pin next to `private-dedup-sequential`.
-
Hendrik Liebau authored
Calling `updateTag()` in a server action made every later read of a cache carrying that tag regenerate for the remainder of the request, including reads of an entry that had just been generated after the invalidation and therefore already reflected it. Two sequential reads of the same cache function during the re-render produced two different values within a single render, and each one repeated the work. `isRecentlyRevalidatedTag` only asked whether a tag appeared in `pendingRevalidatedTags`, with no notion of when the revalidation happened. That array lives for the whole `WorkStore`, which spans a server action and the render that follows it, so once a tag was in it every entry carrying that tag looked stale regardless of when it had been produced. Each pending revalidated tag now records a `revalidatedAt` timestamp taken from the same clock as `CacheEntry.timestamp`, and the renamed `isRevalidatedAfter` reports an entry as stale only when the revalidation is newer than the entry. `CacheEntry.timestamp` is captured before a fill begins, so a fill straddling a revalidation is still discarded, which is the conservative answer for a body that may have read pre-invalidation data. Revalidating the same tag again moves the timestamp forward, since the later invalidation decides which entries are stale. `previouslyRevalidatedTags` are forwarded from an earlier request by a redirecting server action and carry no timestamp of their own, so the work store now records when the request started and treats them as revalidated at that instant. Entries predating the request are still discarded while entries generated during it survive. The hang-detection probe worker and the dev validation worker take that value from the request they serve rather than reading the clock when they start, which would otherwise date every entry from the outer request as older than the request's own start. The `action-dedupe` fixture covers this end to end: it reads a tagged cache twice inside a server action, revalidates the tag, then reads it twice again during the re-render, asserting that each pair shares a value and that the two pairs differ.
-
next-js-bot[bot] authored
-
Zack Tanner authored
## Summary This removes the intermediate `executionMode` from `WorkStore` now that App Page and App Route select their render or prerender pipeline before constructing the store. - Derive ISR error handling from the active `WorkUnitStore` - Derive fetch configuration processing from the active `WorkUnitStore`, including treating cache scopes as owners of their cache policy regardless of the outer render operation - Use explicit render and prerender WorkStore constructors where fetch-metric behavior differs - Keep the App Page render/prerender operation local to the top-level route-module dispatch This completes the migration away from global render-mode state on `WorkStore`, allowing downstream behavior to depend on the more precise work-unit scope instead. <!-- NEXT_JS_LLM -->
-
Zack Tanner authored
## Summary - derive foreground stale-cache revalidation from Work Unit state instead of `WorkStore.executionMode` - propagate that specific policy through `"use cache"` and `unstable_cache` scopes so nested cache and fetch calls preserve their outer behavior - add coverage for foreground ISR revalidation through nested `unstable_cache` scopes This is intended to be a behavior-preserving refactor.
-
Zack Tanner authored
## Summary This introduces explicit `handle()` and `prerender()` entrypoints for App Routes. Request and prerender execution now have distinct configuration and Work Unit paths, removing `executionMode` from the handler context and eliminating all Work Store execution-mode reads from the App Route module. <!-- NEXT_JS_LLM -->
-
Zack Tanner authored
## Summary App Page leaf logic still reads the Work Store execution mode after request rendering and prerendering have already been separated at the entrypoint. This change removes those remaining reads by: - Deriving component-tree behavior from the active Work Unit type. - Relying on request-only boundaries for dynamic Flight payloads and Server Actions. - Selecting request or prerender instrumentation context from the corresponding render pipeline. After this change, App Page only supplies `executionMode` when constructing a Work Store; none of its downstream behavior reads it. Removing the field itself remains a follow-up once App Route and cache consumers have been migrated.
-
Janka Uryga authored
`cheerio.each()` does not handle async things, so this was effectively just a race
-
Luke Sandberg authored
Fork PR #96621 by @ceolinwill, re-opened as a branch PR so the "when deployed" CI job can run — it requires Vercel deployment secrets that GitHub does not expose to pull requests from forks, so it can never pass on the original. **The commit is unchanged and still authored by @ceolinwill.** Please credit them; #96621 should be closed in favor of this one. ### What? `getSharp()` calls `_sharp.block({ operation: ['VipsForeignLoad'] })` to block every image loader, then unblocks a specific allowlist — and that allowlist omitted `VipsForeignLoadSvg`. Because `_sharp` is a module-level singleton, the block is process-wide and permanent: the first `/_next/image` request in a process permanently disables Sharp's SVG loader. `ImageResponse` (`next/og`) rasterizes via resvg and then hands SVG to Sharp, so once that loader is blocked it fails. The symptom is worse than a bad image — the render throws `Input buffer contains unsupported image format`, which surfaces as a **socket hang up / crashed response** on any `ImageResponse` route requested after an uncached image optimization in the same process. Introduced by #96301, which aligned the Sharp allowlist with `detectContentType()` but missed SVG. Fixes #96612 ### How? Adds `'VipsForeignLoadSvg'` to the unblock list. This does not weaken SVG protections for user-supplied images. `detectContentType()` already returns SVG, and untrusted SVG is gated separately by `dangerouslyAllowSVG`, which throws a 400 in `imageOptimizer()` before Sharp is ever invoked. Unblocking the loader only restores Sharp's ability to process SVG that Next.js itself generates. ### Tests The existing `og-api` test is extended to reproduce the exact same-process ordering: render `/og-node`, perform an uncached `/_next/image` optimization (asserting `x-nextjs-cache: MISS`, with a random URL so it can't be served from cache), then render `/og-node` again. Verified locally that this fails without the one-line fix (`socket hang up`, caused by `Input buffer contains unsupported image format`) and passes with it. No regressions in the SVG security coverage — `test/e2e/image-optimizer/dangerously-allow-svg.test.ts` passes 94/94 including all `maintain vector svg` / blur-svg cases, and `test/e2e/image-optimizer/image-optimizer.test.ts` plus the `og-*` suites are green. Co-authored-by:ceolinwill <4393133+ceolinwill@users.noreply.github.com>
-
Aurora Scharff authored
### What? Two Skills assumed a default project layout, and both failed silently when it didn't hold. - `next-cache-components-adoption` hardcoded `./app` for the `cache-components-instant-false` codemod, and checked its work under `app/` too. It now resolves the app directory from `next.config.*` and reads the file count the codemod reports. - `next-dev-loop` probed `/_next/mcp` in preflight, but `NEXT_MCP_URL` for a non-default port was only mentioned much later. The port is now resolved before the first probe. The same `./app` argument is documented for both 16.3 codemods, so the two guides and the codemods reference get a matching Good to know. ### Why? On a `src/app` project the codemod matched nothing and no gate caught it. A path that doesn't exist isn't an error for jscodeshift: it prints `No files selected, nothing to do`, reports `0 ok`, and exits `0`. The root-layout check looked in the same wrong place, and if the app's routes were prerenderable the build passed too, so a repo the migration never touched came out green. On a dev server bound to another port, the preflight probe read "unreachable" and refused to verify while `next dev` was running. Both are silent failures, which is the worst case for instructions an agent runs top to bottom. ### How? - Anchor on `next.config.*` so an agent invoked from a subdirectory doesn't test for `app/` against the wrong `cwd`. - When `app/` and `src/app/` both exist, say so: Next.js builds `app/` and never reads `src/app/`, so those routes are shadowed and unbuilt. Ask which tree to migrate. - Treat `0 ok` as a wrong path rather than a finished run. - Move the `NEXT_MCP_URL` resolution into the `next-dev-loop` preflight. The transforms are fine. Their path regexes match `src/app/...`, and pointed at `./src/app` they convert every segment. `remove-partial-prefetch` has the same shape and hardcoded path, so it's covered here too. Fixes #96649 --------- Co-authored-by:Claude Opus 5 <noreply@anthropic.com>
-
Niklas Mischkulnig authored
ImportMappingReplacement are more efficient: import maps are backed by a single radix tree, as opposed to having to run every single ResolvePlugin's matchers in sequence. This basically undoes https://github.com/vercel/next.js/pull/65870 by @wbinnssmith, but I don't entirely understand why this was done: > This is used to replace ImportMapping replacers for @next/font/local in an upcoming Next.js PR
-
Tim Neutkens authored
## Summary Use `@tailwindcss/turbopack` and a Turbopack CSS loader rule for Tailwind projects generated with Turbopack, avoiding the PostCSS setup in the default path. Keep `@tailwindcss/postcss` and `postcss.config.mjs` for non-Turbopack bundlers, and update create-next-app production coverage to verify generated configuration, dependencies, and rendered Tailwind styles. ## Verification - `pnpm test-start-turbo test/production/create-next-app/templates/app.test.ts -t "should create TailwindCSS project with --tailwind flag"` - `pnpm test-start-rspack test/production/create-next-app/templates/app.test.ts -t "should create TailwindCSS project with --tailwind flag"` <!-- NEXT_JS_LLM -->
-
Aurora Scharff authored
### What? Adds a **Quick start** section to the top of the instant navigation guide. It names the two migrations Instant Navigation is built on, [Cache Components](https://nextjs.org/docs/app/guides/migrating-to-cache-components) and [Partial Prefetching](https://nextjs.org/docs/app/guides/adopting-partial-prefetching), links the adoption Skill for each, and gives a paste-ready prompt that runs both in order. Also rewords the intro to the existing **AI workflow** section, which describes optimizing a single navigation rather than adopting the features across an app. ### Why? The guide explains how instant navigation works, but it never said how to get it. Someone asked to "make navigations instant" landed here and worked through the concepts by hand instead of using the adoption Skills, and so did their coding agent. That has produced migrations that satisfy validation while leaving nothing in the static shell, for example wrapping a whole page in `<Suspense fallback={null}>`. Instant navigations are the result of using Cache Components and Partial Prefetching correctly, so the entry point belongs at the top of this guide, ahead of the concepts, with a line handing readers back to the rest of it. ### How? One paragraph with inline links, then the prompt. The prompt has the agent explain the change and ask how to split the work across PRs before it starts, install the two adoption Skills plus `next-dev-loop` to verify against a running dev server, adopt Cache Components before Partial Prefetching one feature at a time, and report each step as a table of routes and what changed. Co-authored-by:
Claude Opus 4.8 <noreply@anthropic.com>
-
Zack Tanner authored
## Summary App Page rendering currently shares a single implementation that uses the Work Store execution mode to choose between the request and prerender pipelines. This change: - Extracts mode-neutral App Page preparation into a shared step. - Gives request rendering and prerendering separate top-level implementations. - Moves Work Store creation into the corresponding entrypoint. - Makes each path call `renderToStream` or `prerenderToStream` directly, removing the execution-mode dispatch between them. This moves the rendering decision to the App Page boundary and creates a clearer path toward removing execution mode from the Work Store entirely.
-
Zack Tanner authored
## Summary App Router execution intent was previously inferred during WorkStore construction from response capabilities and request state. App Page also carried that intent through its handler context and lazy render API before selecting the rendering operation inside app-render. This change moves those decisions to entrypoints where the work is known: - Reusable output, including build-time generation, fallback shells, and runtime revalidation, selects prerendering. - Request-specific and resumed rendering selects request rendering. - App Page exposes distinct render and prerender operations, so execution mode no longer travels through `AppPageRouteHandlerContext` or the lazy render API. - App Route execution derives its intent from whether the response has an ISR cache key. WorkStore still consumes the explicit mode internally as a transitional seam. Follow-up work can migrate downstream behavior to the active WorkUnitStore and remove the mode from WorkStore entirely. Fixes #96519 ## Verification - `pnpm --filter=next types` - `pnpm test-start-turbo test/e2e/app-dir/segment-cache/static-shell-vary-params-regression/static-shell-vary-params-regression.test.ts` - `pnpm test-start-webpack test/e2e/app-dir/segment-cache/static-shell-vary-params-regression/static-shell-vary-params-regression.test.ts` <!-- NEXT_JS_LLM -->
-
Zack Tanner authored
## Summary `create-component-tree` currently combines `WorkStore.executionMode` with route-level PPR configuration at several leaf call sites to determine whether it can postpone dynamic subtrees and whether the resulting response may be partial. This introduces `AppRenderCapabilities`, derived once at the App Render boundary, containing: - `canPostpone` - `isPossiblyPartialResponse` - `supportsPerSegmentPrefetching` Component tree construction consumes the explicit rendering capabilities instead of independently interpreting the PPR configuration. RSC payload generation likewise consumes `supportsPerSegmentPrefetching` instead of re-deriving the client `S` flag from execution mode and Cache Components, keeping the protocol decision consistent across dynamic, initial, and error payloads.
-
Zack Tanner authored
## Summary - derive an explicit missing-prefetch-hint policy at the App Render boundary - pass that policy through the Flight router-state builders instead of exposing execution mode and related render options Stacked on #96570.
-
Zack Tanner authored
## Summary - replace `WorkStore.isStaticGeneration` with an explicit `'prerender' | 'request'` execution mode - preserve the existing derivation and behavior while making the render/prerender distinction explicit - document that prerendering includes both build-time generation and runtime revalidation - establish groundwork for moving the render decision higher in the stack and replacing downstream mode checks with purpose-specific state Stacked on #96564.
-
Joseph authored
Tying some loose ends in the next cli `### Building specific routes` section.
-
Niklas Mischkulnig authored
Previously, this returned `{} as T` which was unsafe. Now it properly returns `undefined` instead and the caller can decide what the fallback value should be
-