- 22 Sep, 2026 2 commits
-
-
next-js-bot[bot] authored
-
-
- 17 Sep, 2026 1 commit
-
-
Sebastian "Sebbie" Silbermann authored
Backports https://github.com/vercel/next.js/pull/98668 ...to fix deployment tests. Test does not exist on lts-maintenance so this is the only necessary backport. Co-authored-by:
Tobias Koppers <tobias.koppers@googlemail.com> 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>
-
- 11 Sep, 2026 1 commit
-
-
next-js-bot[bot] authored
-
- 10 Sep, 2026 2 commits
-
-
Joseph authored
Backports [#97476](https://github.com/vercel/next.js/pull/97476) ("Fix use cache prerender signal retention") to `next-16-3`. Cherry-picked from 4a95af80, no conflicts. The hunk applied against identical surrounding context; only the line offset differs. <!-- NEXT_JS_LLM -->
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by:Josh Story <gnoff@storyposted.com>
-
Niklas Mischkulnig authored
Backport https://github.com/vercel/next.js/pull/98398Co-authored-by:
Luke Taylor <luket@anthropic.com>
-
- 07 Sep, 2026 1 commit
-
-
Joseph authored
- docs: explain origin matching for allowedOrigins and allowedDevOrigins (#97805) - docs: improve discovery summaries (#97982) - docs(skills): preserve prefetched UI during Partial Prefetching adoption (#97712) - docs: add layout stability guidance for videos and iframes (#98070) - docs: document preloading with Cache Components (#97864) - docs: note that experimental.taint taints process.env (#98145) - docs: add API reference pages for skipProxyUrlNormalize and skipTrailingSlashRedirect (#97967) - docs: keep generateStaticParams during Cache Components migration (docs part of #98209) - docs: Remove version label from Turbopack in Pages Router (#98316) --------- Co-authored-by:
Rich Haines <hello@richardhaines.dev> Co-authored-by:
Aurora Scharff <66901228+aurorascharff@users.noreply.github.com>
-
- 04 Sep, 2026 2 commits
-
-
Luke Sandberg authored
[backport] docs: local development: Rewrite docker section, add Windows Dev Drive and WSL2 instructions (#98272) Backports [docs: local development: Rewrite docker section, add Windows Dev Drive and WSL2 instructions](https://github.com/vercel/next.js/pull/98164) to `next-16-3`. Clean cherry-pick of 5cca033c, no conflicts. Docs-only change to `docs/01-app/02-guides/local-development.mdx`. <!-- NEXT_JS_LLM --> Co-authored-by:
Benjamin Woodruff <benjamin.woodruff@vercel.com>
-
Niklas Mischkulnig authored
Backports #97287
-
- 03 Sep, 2026 2 commits
-
-
Steven authored
Backports https://github.com/vercel/next.js/pull/97278 to 16.3
-
Steven authored
Backports https://github.com/vercel/next.js/pull/94068 to 16.3 Co-authored-by:
Hammad Khan <hammadkhanxcm@gmail.com>
-
- 02 Sep, 2026 1 commit
-
-
Sebastian "Sebbie" Silbermann authored
Got mixed up when syncing backports. Updates the [assertions to match the ones on canary](https://github.com/vercel/next.js/blob/1076c4745318e439062d3464a76881d2b967f886/test/e2e/incremental-cache-path-traversal/index.test.ts#L36-L38). Fixes https://github.com/vercel/next.js/actions/runs/33433820538/job/99648362051#step:35:555
-
- 01 Sep, 2026 1 commit
-
-
Sebastian "Sebbie" Silbermann authored
Backports https://github.com/vercel/next.js/pull/97991
-
- 31 Aug, 2026 3 commits
-
-
next-js-bot[bot] authored
-
Sebastian "Sebbie" Silbermann authored
-
Tim Neutkens authored
Backports [Fix unset crossOrigin in Turbopack manifests](https://github.com/vercel/next.js/pull/97164) to `next-16-3`. <!-- NEXT_JS_LLM -->
-
- 28 Aug, 2026 2 commits
-
-
Niklas Mischkulnig authored
Backport #97942 Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
-
Niklas Mischkulnig authored
Backport https://github.com/vercel/next.js/pull/96525Co-authored-by:
Lazizbek Ergashev <lazerg2@gmail.com>
-
- 27 Aug, 2026 1 commit
-
-
Niklas Mischkulnig authored
Backport https://github.com/vercel/next.js/pull/97792
-
- 25 Aug, 2026 4 commits
-
-
next-js-bot[bot] authored
-
Joseph authored
## Summary - docs: remove experimental note from runtime prefetching (#96615) - docs: proxy event argument (#96435) - docs: correction to dynamicParams migration (#96624) - docs: quote the dynamicParams build error in a blockquote (#96633) - docs: use relative doc links in instant-navigation error pages (#96672) - docs: document ! exclusion and src/ prefix for --debug-build-paths (#96703) - docs: instant navigation quick start with an adoption prompt (#96663) - docs (Skills): stop assuming app/ at the root and port 3000 (#96696) - docs: present each Skill as steps in the AI agents guide (#96751) - docs: update redirected links to current targets (#96723) - docs: add authentication with Cache Components guide and iron-session example (#95802) - docs: link View Transitions skill on skills.sh and clarify the example prompt (#96863) - Add a `turbopackChunking` documentation page for pages router (#96698) - docs: add `export const dynamic = 'force-static'` to Route Handlers example on Static Exports (#96964) - docs: runtime prefetching -> optimizing prefetching (#96934) - Fix typo in Data Access Layer section (#87202) - docs: rename repo to repository for consistency (#87849) - docs(mdx): fix package name in .md handling section (#97131) - docs: fix Link prefetch grammar and Client Components wording (#97132) - docs: align Cache Components authentication guide title (#97143) - docs: create client-side fetching guide (#96341) - docs: clarify client cache freshness after hydration (#97180) - docs: server client and directives (#96145) - Update authentication diagram URL (#97320) - docs: align SPA guide reducer example with React conventions (#97341) - docs: app router reference accuracy (#97477) - docs: mention Valibot as validation library option in forms guides (#97468) - docs: warn when catching permanentRedirect (#97496) - [docs] fix: grammar typos in linking and navigating guide (#95544) - docs: rename Vercel Edge Config to Global Config in redirecting guide (#97456) - docs: document metadata pagination field (#95509) - docs: outlining and lcp (#96942) - docs: adjust interactive app guide (#97558) - docs: generateMetadata values should be serializable with use cache (#97551) - Fix stale cross-references in skills/ (#97566) - Improve Cache Components sync IO migration guidance (#97572) - docs: Explicit cache output description (#97548) - docs: document deploymentId build ID override and Pages Router skew in 16.2 (#97645) - docs: drop stale Route Handlers restriction from `use cache: private` (docs part of #97349) - docs: clarify beforeInteractive placement for root layouts (#97643) - docs: Adapters entry page lists its children pages twice (#97677) - docs: correct the upper stale bound for App Shell exclusion in cacheLife (#97653) - Improve Partial Prefetching adoption checks (#97637) - docs: fix parallelRouteKey parameter name in useSelectedLayoutSegment(s) (#97710) - docs(adapters): document assetsHashes and routing.middlewareMatchers (#96536) - docs: note that response headers must be set before calling handle() in a custom server (#97693) - Document catchError for the Pages Router (#97748) - docs: fix typos and correctness issues in App Router docs (#97823) - docs: param access on use-server (#97865) - docs: clarify revalidateTag profile expire semantics (#97836) --------- Co-authored-by:
Aurora Scharff <66901228+aurorascharff@users.noreply.github.com> Co-authored-by:
Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by:
Rich Haines <hello@richardhaines.dev> Co-authored-by:
vercel[bot] <35613825+vercel[bot]@users.noreply.github.com> Co-authored-by:
Aurora Scharff <aurora.sofie@gmail.com> Co-authored-by:
Sam Poder <sampoder@berkeley.edu> Co-authored-by:
Masashi Kawafuji <masashikawafuji@proton.me> Co-authored-by:
Akseli Palmer <akseli@toddsden.com> Co-authored-by:
Tim Neutkens <tim@timneutkens.nl> Co-authored-by:
Jarren <sanjose.jarren@gmail.com> Co-authored-by:
Marcos Hernanz <96699542+marcoshernanz@users.noreply.github.com> Co-authored-by:
Pavan Shinde <pavann97@gmail.com> Co-authored-by:
Reza Karimzadeh <r.karimzadeh1998@gmail.com> Co-authored-by:
Fabian Hiller <hillerfabian11@gmail.com> Co-authored-by:
David Alexandru Ilie <david@davidilie.com> Co-authored-by:
Sean Beirnes <127370575+seanbeirnes@users.noreply.github.com> Co-authored-by:
Rich Haines <22930449+molebox@users.noreply.github.com> Co-authored-by:
KAM <biukam.w@gmail.com> Co-authored-by:
Jiwon Choi <devjiwonchoi@gmail.com> Co-authored-by:
Jude Gao <jude.gao@vercel.com> Co-authored-by:
Said Nasser <sdnssr001@gmail.com> Co-authored-by:
Eddy (Frontend Engineer) <101346918+leejpsd@users.noreply.github.com> Co-authored-by:
Tobias Koppers <tobias.koppers@googlemail.com> 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>
-
- 24 Aug, 2026 1 commit
-
-
Sebastian "Sebbie" Silbermann authored
Co-authored-by:Jiwon Choi <devjiwonchoi@gmail.com>
-
- 21 Aug, 2026 1 commit
-
-
next-js-bot[bot] authored
-
- 20 Aug, 2026 2 commits
-
-
Sebastian "Sebbie" Silbermann authored
-
Tim Neutkens authored
Backports [Fix Turbopack worker chunk loading with asset prefix](https://github.com/vercel/next.js/pull/96636) to `next-16-3`. <!-- NEXT_JS_LLM --> Co-authored-by:
Tobias Koppers <tobias.koppers@googlemail.com>
-
- 19 Aug, 2026 1 commit
-
-
Niklas Mischkulnig authored
Backports #97372
-
- 18 Aug, 2026 1 commit
-
-
Niklas Mischkulnig authored
Backport of https://github.com/vercel/next.js/pull/97353Co-authored-by:
vercel-fleet[bot] <308483924+vercel-fleet[bot]@users.noreply.github.com>
-
- 15 Aug, 2026 1 commit
-
-
Tim Neutkens authored
Backports [Fix catch-all index page being served for every other slug](https://github.com/vercel/next.js/pull/96553) to `next-16-3`. <!-- NEXT_JS_LLM --> Co-authored-by:
Andrew Clark <git@andrewclark.io>
-
- 14 Aug, 2026 1 commit
-
-
Hendrik Liebau authored
Backports [Scope app-entry export validation to files inside the app directory (#97350)](https://github.com/vercel/next.js/pull/97350) to `next-16-3`. Fixes #96859 on the 16.3 line. The regression came from #94962, which is present in `next-16-3` (16.3.1) and absent from `next-16-2`, so 16.3 is the only release branch that needs it. Clean cherry-pick with no conflicts; every touched file is byte-identical to the merged canary commit. `cargo test -p next-custom-transforms --test errors react_server_components` passes on this branch (33 fixtures). The end-to-end suite is left to CI. <!-- NEXT_JS_LLM --> Co-authored-by:
Rodrigo Arias <rodrigo@arias.me>
-
- 13 Aug, 2026 9 commits
-
-
next-js-bot[bot] authored
-
Jude Gao authored
Backports #97327 ("Revert i18n localization change for dynamic Pages API routes (#94905)") to `next-16-3`. Clean cherry-pick of `2f84a1f2` — `next-16-3` carries the exact code being reverted, so it applies as-is. Restores i18n locale prefixing for dynamic Pages API routes, so the emitted matcher and the adapter's i18n rules agree again on whether `/api/...` carries a locale prefix. When they disagree the matcher is unreachable and requests fall through to `/{locale}/404`. Pairs with the adapter revert (nextjs/adapter-vercel#101, published as `adapter-vercel@0.0.1-beta.26`). Full rationale and reproduction in #97327. -
Luke Sandberg authored
Backports the following to `next-16-3`, as a pair: - #96941 — "[turbopack] Retain fewer stale cache versions and use a TTL" (`ae1e53a1`) - #97268 — "Add the mtime fallback back" (`52a3410d`) The second fixes a bug in the first: #96941 changes the `CURRENT` file format from a bare big-endian `u32` to a JSON object, and an existing cache directory in the old format could no longer be aged. #97268 adds the mtime fallback so an unparsable `CURRENT` is aged by its mtime instead of failing. They only make sense together, hence one branch. Both cherry-picked with `-x`, no conflicts. Every touched source file is byte-identical to canary. ### Verification on this branch - `cargo check`, `cargo clippy --all-targets`, `cargo fmt --check` on `turbo-persistence` and `turbo-tasks-backend` — clean - `cargo test -p turbo-persistence -p turbo-tasks-backend` — all pass, 0 failures - includes the `db_versioning` tests, notably `test_unparsable_current_falls_back_to_mtime::case_1_old_u32_format` (the old-format compatibility case #97268 restores) - `cargo metadata --locked` — `Cargo.lock` consistent with the manifests, no lockfile update needed - `pnpm --filter=next types`, prettier, eslint — clean - `pnpm build-all` — 18/18 tasks - `test/production/next-server-nft` — 5/5 tests, 5/5 snapshots pass (covers the traced `turbopack-cache-seed.js`) ### End-to-end verification against a real old-format cache `create-next-app@16.3.0` + `next build` (with `turbopackFileSystemCacheForBuild`) on released `next@16.3.0` writes a `CURRENT` in the old pre-JSON format — a bare big-endian `u32` (`0000 0008`), 30M cache. This branch was then applied with `pnpm pack-next -p <app> -- --release` (release binary confirmed to contain `TURBO_ENGINE_VERSION_TTL_DAYS` and the new `CURRENT` field names), and two arms were run from an identical starting state — same cache, same code, only the env var differing: | Arm | Build | Cache dirs after | | --- | --- | --- | | `TURBO_ENGINE_VERSION_TTL_DAYS=0` | exit 0 | old dir **deleted**, 1 remains | | default TTL (3 days) | exit 0 | old dir **retained**, intact at 30M, 2 remain | The retention arm is the meaningful control: without #97268's fallback, `read_current_version` would error on the bare-`u32` file, the age would become `Duration::MAX`, and the directory would be evicted in *both* arms. Retention under the default TTL is direct evidence the mtime fallback works. Also confirmed: - new `CURRENT` is written as JSON: `{"max_sequence_number":8,"commit_time":"..."}` - retention cap holds: seeded 4 version dirs → build left exactly 2 (current + one most-recently-used other) - clean deletion, no `DELETION_PREFIX` leftovers in any run - `TURBO_ENGINE_VERSION_TTL_DAYS=notanumber` warns (`expected a whole number of days`) and falls back to the 3-day default rather than failing <!-- NEXT_JS_LLM -->
-
Andrew Clark authored
Backports #97128 ("Fix: Optimistic routing bugs leading to repeated prefetch loops") to `next-16-3`. Fixes an infinite prefetch loop in optimistic routing. A proxy that rewrites every URL to inject a leading path segment — i18n with the default locale hidden from the URL, so `/one/two` is served as `/en/one/two` — combined with a fully dynamic target route like `/[locale]/[...pages]`, produces a prefetch that never settles. When a prefetch response came back, the client never checked whether the rendered tree matched the one it had requested. When the params baked into the request were wrong because of the rewrite, the task kept re-attempting to fulfill the missing data and looped forever. The prefetch path now records a dynamic-rewrite marker on the local route definition when the response's tree diverges from the requested one, which disables further optimistic resolution of that route and invalidates the entries derived from it. This is the same strategy normal navigation responses already used, now applied to the prefetch path. A second, related bug is also fixed: parallel routes with conflicting dynamic params at the same level (`@modal/[...catchAll]` next to `[username]`) can't be distinguished by the traversal algorithm, which assumes each segment resolves independently without inspecting sibling branches. When that scenario is detected, optimistic routing is now disabled for the conflicting route rather than binding one branch's URL parts to another branch's params. ### Verification on this branch Cherry-picked from `5942b37a`. Three source files conflicted, all because `next-16-3` predates the post-16.3.0 refactor that split the client's response decoder into its own module: - `segment-cache/decode-server-response.ts` — this file does not exist on this branch; it was extracted out of `navigation.ts` after 16.3.0. Its change (tracking whether the decoded tree's segment identities diverge from the base request tree) was ported into `navigation.ts`, where the equivalent logic still lives. Canary decodes a compact transport tree and compares segment identities inline during the walk; this branch instead merges the response patch onto the base `FlightRouterState` before converting it to a `RouteTree`. The check is therefore re-expressed as a read-only walk in `convertServerPatchToFullTree` that compares each server patch against the base tree it is applied to, following canary's descent (`convertServerPatchToFullTreeImpl`) exactly and using the same comparison rules: segment identity via `matchSegment`, page segments matched modulo embedded search params, server-filled `__DEFAULT__` segments ignored, and inactive parallel-route branches (those carrying a refresh state in the base) skipped. The result is threaded out through `NavigationSeed.treeDivergedFromBase`. - `segment-cache/cache.ts` — the consuming block in `fetchSegmentPrefetchesUsingDynamicRequest` (mark-as-dynamic-rewrite, invalidate derived entries, reject with immediate expiry) is byte-identical to canary. The surrounding conflicts were only incidental: the `RouteTreeAccumulator` type gaining `treeDivergedFromBase`, and canary's transport-decoder call vs. this branch's `convertRootFlightRouterStateToRouteTree`. Resolved by keeping this branch's calls and adding the new field to the accumulators. Canary's inline `NavigationSeed` construction in `writeDynamicTreeResponseIntoCache` does not apply here because that function delegates to `convertServerPatchToFullTree`, which now carries the field. - `router-reducer/create-initial-router-state.ts` — a one-line accumulator initializer; kept this branch's `convertRootFlightRouterStateToRouteTree` call and added `treeDivergedFromBase: false`. The other touched source files applied cleanly and are byte-identical to canary: `segment-cache/optimistic-routes.ts` (the parallel-route conflict detection) and `route-params.ts` (exporting `canonicalizeURLPart`), along with `ppr-navigations.ts`, the small cleanly-applied hunk in `navigation.ts`, and every test fixture. `tsc` passes on the `next` package for all files touched here. Behavioral verification is left to CI on this branch; the change carries the `proxy-prefix-rewrite-prefetch-loop` and `modal-catchall-sibling-dynamic-prefetch-loop` end-to-end suites plus additions to the `optimistic-routing` suite. Opened as a draft because the `decode-server-response.ts` → `navigation.ts` port is a manual re-implementation across the refactor boundary rather than a mechanical cherry-pick. The divergence walk in `convertServerPatchToFullTree` is the part most worth a close review. <!-- NEXT_JS_LLM --> -
Andrew Clark authored
Backports #97050 ("Fix Nav Inspector request loop on repeat captures") to `next-16-3`. With the Nav Inspector enabled, clicking a `<Link prefetch={true}>`, closing the inspector, navigating home, re-enabling it, and clicking the same link left the app hung in a pending "Compiling…" state while it fired prefetch requests in an infinite loop (~30/sec). The Instant Navigation Testing lock restricted navigation reads to entries created within the current lock scope (`ownedEntries`), enforced as a post-hoc filter after the cache lookup. Because the segment cache resolves lookups by most-specific-match, a previous scope's runtime-prefetch entries at concrete param keypaths kept winning the lookup, the filter kept rejecting them, and the locked prefetch created its replacement at a more generic keypath that could never win — so every scheduler pass discarded and refetched forever. Rather than patch the filter, the fix replaces the `ownedEntries` mechanism with a per-scope segment `CacheMap`. Each lock scope owns a private map that starts empty and is discarded at release, so a captured navigation structurally observes only data fetched under the lock. The map is bound to a unit of work when it is created: a prefetch task captures its map when scheduled (`PrefetchTask.segmentCacheMap`, the single place that consults lock state), a locked navigation inherits its driving task's map, and everything else — unlocked navigations, hydration, refreshes, history-traversal restores, server actions and patches — binds to the shared map. Reads and response writes receive the map explicitly, so a request that straddles a scope boundary still writes into the map its entries live in. In production builds without the testing API this compiles down to the previous single-map behavior, so the non-testing paths are unchanged. ### Verification on this branch Cherry-picked from `5dc3ae1f`. Three files conflicted; each was resolved by keeping the release branch's existing code shape and applying only the fix's actual change — threading the segment `CacheMap` through as an explicit parameter. - **`refresh-reducer.ts`** and **`restore-reducer.ts`** — the conflicts were confined to the import block. Canary imports `convertServerPatchToFullTree` from `./segment-cache/decode-server-response`, a module that doesn't exist on this branch; `next-16-3` still imports it from `./segment-cache/navigation`. I kept the release branch's import source and added the new `segmentCacheMap` import alongside it. The function-body changes (passing `segmentCacheMap` as the shared map) applied cleanly, and the `startPPRNavigation`/`spawnDynamicRequests` argument order lines up with this branch's signatures. - **`cache.ts`** — the substantive one. `next-16-3` predates the post-16.3.0 segment-cache refactors, so three areas differ from canary and had to be adapted rather than taken verbatim from the patch: (1) `RouteTree` is still non-generic here (`RouteTree`, not `RouteTree<RSCSegmentData | null>` — this branch has no `RSCSegmentData` and the tree doesn't carry render data), so the three signatures the patch retyped were kept as plain `RouteTree`; (2) `writeSegmentBundleResponse` still has the older `StaticShell`/`else` re-key split guarded by `__NEXT_VARY_PARAMS`, versus canary's single `upsertSegmentEntry` — I kept the release-branch logic and threaded `map` into both of its `upsertSegmentEntry` calls; (3) `writeDynamicRenderResponseIntoCache` and `writeSeedDataIntoCache` still use the `flightDatas` + `CacheNodeSeedData` write model rather than canary's route-tree-carries-data model — I kept the release-branch traversal and threaded `map` into each `writeSeedDataIntoCache` / `fulfillEntrySpawnedByRuntimePrefetch` call. Everything else in `cache.ts` — the `ownedEntries` removal, the `segmentCacheMap` export, `insertEmptySegmentCacheEntry`, and the `map` parameter added to every read/write helper — applied cleanly and is identical to canary. I confirmed no stale references to the removed `ownedEntries` / `readSegmentCacheEntry` / `navigationLockPrefetch`-param APIs remain, and that every call site of the retyped helpers passes a map. The remaining files applied without conflict. `server-patch-reducer.ts`, `navigation-testing-lock.ts`, `navigation-testing-lock.disabled.ts`, and the `instant-navs-devtools` test are byte-identical to canary. `create-initial-router-state.ts`, `ppr-navigations.ts`, `server-action-reducer.ts`, `navigation.ts`, and `scheduler.ts` differ from canary only in pre-existing `next-16-3` divergence (the older transport-data / route-tree models); the fix's own hunks (the `segmentCacheMap` threading) applied to them cleanly. No local typecheck was run — this fresh worktree has no `node_modules` and installing it carries the known corepack/SWC-binary gotchas — so behavioral and type verification is left to CI on this branch, which carries the `instant-navs-devtools` regression test from #96692. **Reviewer, focus here:** the `writeSegmentBundleResponse` resolution in `cache.ts` (area 2 above) is the hunk I'd most like a second pair of eyes on. I preserved this branch's `StaticShell`/`else` re-key branch structure and only inserted the `map` argument into its two `upsertSegmentEntry` calls; please confirm that routing both branches' writes through the task's bound map (rather than the module-level `segmentCacheMap`) is the correct behavior for the older re-key logic. <!-- NEXT_JS_LLM --> Co-authored-by:Sam Selikoff <sam.selikoff@gmail.com>
-
Luke Sandberg authored
Backports #97190 ("[test] Compile the middleware redirect routes up front in dev") to `next-16-3`. <!-- NEXT_JS_LLM --> Co-authored-by:Hendrik Liebau <mail@hendrik-liebau.de>
-
Sebastian "Sebbie" Silbermann authored
Backports https://github.com/vercel/next.js/pull/96919
🤖 Generated with [Claude Code](https://claude.com/claude-code) -
Hendrik Liebau authored
Backports #96936 ("[refactor] Rename `encodeCacheTag` to `encodeHeaderSafe`") and #96937 ("Encode the cache item name built by `unstable_cache`") to `next-16-3`. Fixes #76286. A cache implementation may serialize cache metadata into HTTP request headers, whose values are limited to Latin-1. `unstable_cache` assembles a cache item name from the request URL and the name of the cached callback, and neither part was encoded. When that name holds a character above U+00FF the conversion throws before the request is dispatched, so the read never reaches the cache and the write that follows it fails the same way. Nothing is stored, nothing is found, and the entry falls back to the origin on every render. The reachable case is a non-ASCII query parameter on any dynamic route that calls `unstable_cache`, whether or not the route reads `searchParams`, because `URLSearchParams` returns decoded keys and values while the pathname stays percent-encoded. The rename is folded in because it is the prerequisite: #96937 imports `encodeHeaderSafe` from `server/lib/encode-header-safe`, which the rename creates. It carries no behavior change, the function body is identical apart from the parameter name, and the two were stacked in this same order on canary. ### Verification on this branch Cherry-picked from `1f0cd93b` and `4286a42e` in that order, with no conflicts. `packages/next/src/server/web/spec-extension/unstable-cache.ts` is not byte-identical to canary, because the release branch predates the unrelated `willConsumerServerCache` change and keeps `workStore.isStaticGeneration` at those two call sites. The diff this backport applies to that file is exactly the encoding change and nothing else. Every other source file is byte-identical to canary, and no reference to the old `encodeCacheTag` name remains. Behavioral verification is left to CI on this branch; the change carries the `non-ascii-cache-item-name` end-to-end suite, which exercises a real cache handler. <!-- NEXT_JS_LLM --> -
Hendrik Liebau authored
[backport] Discard only cache entries that predate a tag revalidation, and reuse completed entries (#97314) Backports #96726 ("Discard only cache entries that predate a tag revalidation") and #96727 ("Reuse completed cache entries for the rest of a request") to `next-16-3`. 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`, and that array lives for the whole `WorkStore`, which spans a server action and the render that follows it. 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. The second change fixes a `'use cache: private'` function executing its body twice when it is called twice in one request, which defeats the preload-then-read shape that motivates a preload in the first place. The intra-request dedupe map dropped an entry as soon as its fill completed, so it only ever covered concurrent invocations, and private caches have no cache handler in production to fall back to. Completed invocations now move into `completedCacheInvocations` on the work store instead of being dropped. The two are backported together because #96727 builds on the discard checks that #96726 restructures. They were stacked in this order on canary, and #96727 conflicts in `test/e2e/app-dir/use-cache/use-cache.test.ts` when applied alone. ### Verification on this branch Cherry-picked from `5da1c1ae` and `1ff6a803` in that order, with no conflicts. All source files are byte-identical to canary. Behavioral verification is left to CI on this branch; the changes carry the `action-dedupe`, `dedup-sequential` and `private-dedup-sequential` fixtures in the `use-cache` suite, and a handler-call count assertion in `use-cache-custom-handler`. <!-- NEXT_JS_LLM -->
-