1. 02 Sep, 2026 8 commits
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.15 · 69ec884e
      next-js-bot[bot] authored
      69ec884e
    • Luke Sandberg's avatar
      Reduce Turbopack cache size with per-family compression (#97714) · 5a0f57d9
      Luke Sandberg authored
      ## What?
      
      Adds per-family compression configuration to `turbo-persistence` and
      configures the Turbopack filesystem cache according to each keyspace's
      access pattern:
      
      | Family | Compression | Reason |
      | --- | --- | --- |
      | Infra | LZ4 HC level 4 | Preserve LZ4 decode performance while
      improving write-time compression |
      | TaskMeta | LZ4 HC level 4 | Preserve latency-sensitive metadata reads
      |
      | TaskCache | LZ4 HC level 4 | Preserve latency-sensitive task-cache
      reads |
      | TaskData | zstd level 3 | Prioritize the dominant disk-size
      opportunity |
      
      The low-level configuration exposes only the three presets this database
      needs: LZ4, LZ4 HC4, and zstd3. Compression is applied consistently to
      SST blocks, blob values, and compaction output. Each database owns a
      `ThreadLocal` that lazily creates one lock-free zstd decompressor per
      participating thread; the linked zstd reports each context as about 96
      KiB, and all contexts are released when the database drops.
      
      Each meta file stores its family's length-prefixed, bincode-encoded
      compression preset once. SST and blob headers remain unchanged,
      including the 12.5% minimum-savings fallback to uncompressed blocks. On
      normal database open, the stored marker must match the runtime
      `FamilyConfig`; a mismatch, invalid/truncated preset, or pre-marker meta
      file is rejected before reads are served. This intentionally requires a
      fresh/versioned cache after a codec change, consistent with
      `turbo-persistence`'s existing no-cross-version-compatibility policy.
      
      The marker also removes the duplicated keyspace-to-codec mapping from
      `sst_inspect`: it reads the codec directly from metadata.
      `turbo-persistence-tools` can inspect metadata without supplying a
      Turbopack-specific family configuration.
      
      ## Why?
      
      LZ4 decode performance is important for cache query latency, but using
      one codec for every keyspace leaves a substantial disk-size opportunity
      in TaskData. The families do not have the same tradeoff: metadata and
      task-cache reads should stay on the LZ4 decoder, while TaskData can
      spend modestly more CPU to reduce persistent cache size.
      
      The final three-workload A/B reduced fresh cache directories by **20.61%
      overall**, with no measured cold/write or warm/read regression (the
      observed -3.42% / -2.39% should be treated as noise, not a speed claim).
      
      ## How?
      
      ### Real Next.js cache A/B
      
      The complete A/B was re-run after the final fixed-preset,
      bincode-marker, and database-owned thread-local revision. Both the
      unchanged base worktree and final proposed working tree were
      bootstrapped with `pnpm install --frozen-lockfile` and `pnpm build-all`,
      using locally compiled native bindings on the same 8-vCPU Intel Xeon VM
      (16.3 GiB RAM, Linux 6.18.40, Node 24.14.1). Each workload used three
      fresh-cache builds and five warm-cache rebuilds; the table reports
      medians.
      
      ```sh
      TURBO_ENGINE_IGNORE_DIRTY=1 NEXT_TELEMETRY_DISABLED=1 \
        node packages/next/dist/bin/next build <fixture> --turbopack
      ```
      
      `test/e2e/filesystem-cache` additionally used `ENABLE_CACHING=1`. The
      other fixtures temporarily enabled
      `experimental.turbopackFileSystemCacheForBuild`; those fixture changes
      are not in this PR.
      
      | Workload | Cache size | Cold/write | Warm/read |
      | --- | ---: | ---:| ---: |
      | `test/e2e/filesystem-cache` | **-20.62%** | -2.24% | -3.00% |
      | `test/e2e/app-dir/app-rendering` | **-20.11%** | -6.04% | -1.47% |
      | `test/e2e/app-dir/client-reference-chunking` | **-21.02%** | -1.45% |
      -3.56% |
      | Combined medians | **-20.61%** (96.810 → 76.862 MiB) | **-3.42%** |
      **-2.39%** |
      
      Per-family inspection of a final filesystem-cache build, using the
      marker-derived codec:
      
      | Family | Total file size | Value-block savings |
      | --- | ---: | ---: |
      | Infra | 52 B | n/a |
      | TaskMeta | 6.31 MB | 29% |
      | TaskData | 18.17 MB | 66% |
      | TaskCache | 1.65 MB | n/a |
      
      The originally planned `app` and `app-static` fixtures could not run as
      standalone builds: `app` hit the existing Edge-runtime `process.cwd()`
      build failure, and `app-static` required an external data endpoint
      during page-data collection. They were replaced with the two successful
      repository fixtures shown above under the same base/proposed
      methodology.
      
      ### Temporary crate benchmark instrumentation
      
      The codec-specific Criterion cases were used locally to gather receipts,
      then removed from the delivered patch per review.
      
      | Codec | Synthetic write | vs LZ4 | Uncached get | Cached get | DB size
      |
      | --- | ---: | ---: | ---: | ---: | ---: |
      | LZ4 | 38.173 ms | baseline | 7.3004 µs | 10.735 µs | 21.59 MiB |
      | LZ4 HC4 | 256.31 ms | **+571.7%** | 3.4853 µs | 8.5467 µs | 21.57 MiB
      |
      | zstd3 | 57.790 ms | **+51.4%** | 6.2460 µs | 9.5323 µs | 21.49 MiB |
      
      The synthetic workload applies one codec to the entire database and
      barely separates codecs by size, so it is not representative of the real
      TaskData distribution. The all-HC write regression is real but confined
      to smaller families in the actual configuration. Cached reads do not
      decompress blocks, and the read samples contain substantial
      ordering/outlier noise. The real-cache A/B is the read-regression guard.
      
      ## Vercel Site
      
      ### Size
      
      2.9G	canary
      2.2G	this PR
      
      a 25% savings
      
      ### Performance
      
      Cold build (n=5), warm build (n=3), medians:
      
      | Scenario | Metric | Canary | Compression | Δ |
      |---|---|---|---|---|
      | **Cold** | wall (s) | 71.28 | 72.86 | +2.2% |
      | | user (s) | 555.21 | 570.23 | +2.7% |
      | | sys (s) | 94.49 | 95.00 | +0.5% |
      | | maxRSS (GB) | 17.95 | 17.98 | +0.2% |
      | **Warm** | wall (s) | 15.00 | 15.32 | +2.1% |
      | | user (s) | 7.59 | 9.98 | +31% |
      | | sys (s) | 12.79 | 12.87 | +0.6% |
      | | maxRSS (GB) | 3.78 | 3.86 | +2.0% |
      
      maxRSS converted at 1 GB = 2^30 bytes.
      
      Looking at tracing data i see in a cold build `persist` span went from
      5.06s duration using 63s cpu time to 6.04s using 73s cpu time, a ~20%
      regression. Which explains the cpu regression and the time progression.
      
      Because the time regression is in the `persist` span during shutdown the
      added latency is somewhat hidden.
      
      Of course we also see a small wall/user time regression in warm builds
      due to the extra decompression costs for zstd.
      
      ### Verification
      
      - `cargo test -p turbo-persistence` (79 tests)
      - `cargo test -p turbo-tasks-backend` (99 unit tests plus integration
      suites)
      - `cargo test -p turbo-persistence-tools`
      - `cargo test -p turbo-persistence --all-targets --no-run`
      - `cargo fmt --all -- --check`
      - `cargo clippy -p turbo-persistence -p turbo-persistence-tools -p
      turbo-tasks-backend --all-targets -- -D warnings`
      - `cargo check -p turbo-persistence -p turbo-persistence-tools -p
      turbo-tasks-backend`
      - `pnpm lint-ast-grep`
      - `pnpm build-all`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 621238c3-5a53-431b-8661-8c5b2920d55d -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      5a0f57d9
    • Sebastian "Sebbie" Silbermann's avatar
      [test] Skip hooks of suites skipped by a lazy `@force-gate` (#98169) · 5b8c866c
      Sebastian "Sebbie" Silbermann authored
      A `describe` gated by a lazy `// @force-gate` (a condition read off the
      fixture's resolved config, like `cacheComponents`) cannot be skipped at
      collection time, so the gate runtime force-passes its tests at runtime
      and `nextTestSetup` skips the fixture build. Hooks registered inside
      such a `describe` still ran, because only the `it`/`test` globals were
      wrapped. A hook that touches the `next` instance (for example a
      `beforeEach` that reads `next.cliOutput`) then failed with `next
      instance is not initialized yet` and failed the supposedly skipped
      suite.
      
      The gate runtime now wraps the
      `beforeAll`/`afterAll`/`beforeEach`/`afterEach` globals as well and
      skips a hook registered under a lazy `@force-gate` when that gate
      evaluates false against the fixture's resolved config. Only a false lazy
      force-gate skips a hook: an inverted `@gate` still runs its tests and
      therefore needs its hooks, and a static `@force-gate` already skips the
      whole `describe` at collection time. The hooks `nextTestSetup` registers
      itself are marked with the new `ungatedHook` helper so that the skip
      decision and the fixture cleanup still run.
      
      The `cacheComponents disabled, edge app router` describe in
      `test/e2e/cache-handlers-upstream-wiring` is converted from the
      `process.env.__NEXT_CACHE_COMPONENTS` `describe.skip` ternary to `//
      @force-gate !cacheComponents`, replacing a fake-green skip and
      exercising the fixed path. The `!deploy` conversion of the remaining
      describes is left to the branch that introduces the `deploy` condition.
      Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
      5b8c866c
    • Benjamin Woodruff ‮'s avatar
      docs: local development: Rewrite docker section, add Windows Dev Drive and WSL2… · 5cca033c
      Benjamin Woodruff authored
      docs: local development: Rewrite docker section, add Windows Dev Drive and WSL2 instructions (#98164)
      
      Follow-up to
      https://vercel.slack.com/archives/C046HAU4H7F/p1787344658655399
      
      Summary:
      - Move system configuration changes into it's own section, separate from
      application and project configuration changes.
      - The Docker section was very light on details and didn't do a good job
      of explaining why this problem happens.
      - Also suggest
      https://docs.docker.com/desktop/features/synchronized-file-sharing/ for
      Docker and explicitly discourage `watchOptions.pollIntervalMs` as a
      workaround.
      - Suggest Windows Dev Drive
      (https://learn.microsoft.com/en-us/windows/dev-drive/). I don't have
      experience with it, but Microsoft recommends it and claims it improves
      filesystem performance.
      - Recommend trying WSL 2.
      5cca033c
    • Niklas Mischkulnig's avatar
      Bump swc to v77 (#97407) · 538f3f68
      Niklas Mischkulnig authored
      There have been breaking changes to the AST:
      - `BlockStmtOrExpr` is now `ArrowFunctionBody`
      - function bodies are `FunctionBody` instead of `BlockStmt`
      - JSX text literals are `Wtf8Atom`, instead of `Atom`
      538f3f68
    • next-js-bot[bot]'s avatar
    • Luke Sandberg's avatar
      turbo-tasks-backend: parent_count-driven garbage collection (#97282) · 8ea76d64
      Luke Sandberg authored
      Adds garbage collection, built on the `parent_count` reference counting
      
      ### How collection works
      
      * we scan all storage shards for collectible tasks to seed the sweep
      * For each collectible task we
          1. mark it as deleted
          2. remove all outgoing edges
          3. queue new tasks for deletion if the edge removals triggered it
      
      For removing edges we rely on the existing `CleanupOldEdges` operation,
      though it is enhanced to collect the tasks that become collectible as
      edges are removed
      
      Deletion markers are transformed into tombstones by persistence and then
      dropped from memory by eviction.
      
      ### Coordinator changes
      
      GC mutates the graph, so we exclude other tasks from running while it
      works. When gc completes we hand off to persistence which switches to
      the existing copy on write mode.
      
      The subtle piece is `GcPhase::into_snapshot`: GC has to hand its
      exclusion directly to the snapshot that tombstones what it collected.
      Swapping the flags under one lock leaves no window where an operation
      could start and resurrect a just-collected task.
      
      ### Enabling it
      
      Off by default; `TURBO_ENGINE_GC` turns it on, also requires eviction to
      be enabled (otherwise deleted tasks persist in RAM)
      
      `prevent_gc()` becomes real, pinning the calling task through
      `transient_ref_count`.
      8ea76d64
    • Luke Sandberg's avatar
      Remove the worker thread for turbopack builds (#96862) · bcfa15d0
      Luke Sandberg authored
      Avoid spawning a worker thread to run turbopack
      
      The typical arguments for worker threads are that they isolate the JS
      heap and enable parallelism, but turbopack does both these things by
      default (native heap is isolated, the js deps are minor and have a lot
      of overlap with existing next server deps).
      
      There is also no substantial parallelism opportunity from worker threads
      that aren't immediately delivered by turbopacks execution model
      
      ## Benchmarks
      
      Measured with a paired A/B harness that alternates `head` and `base`
      builds so thermal drift and background load cancel out, discarding a
      warmup build per variant and clearing `.next` before each run. Both
      variants are the same commit except for this change. 35 paired
      iterations on a default `create-next-app` (App Router, TS), Node
      20.11.1, Apple silicon.
      
      | Metric | this PR | canary | Diff | 95% CI | Wins |
      | --- | --- | --- | --- | --- | --- |
      | `next-build` total | 2478 ms | 2595 ms | **-117 ms (4.5%)** | [50,
      183] | 30/35 |
      | `run-turbopack` | 1228 ms | 1335 ms | -107 ms (8.0%) | [62, 152] |
      31/35 |
      | overhead (total - turbopack) | 1250 ms | 1260 ms | -10 ms (0.8%) |
      [-27, 46] | 20/35 |
      | wall clock | 2775 ms | 2888 ms | -112 ms (3.9%) | [45, 180] | 30/35 |
      | peak RSS | 1175 MiB | 1195 MiB | **-19 MiB (1.6%)** | [3.4, 35.3] |
      22/35 |
      
      Significant by both a paired t-test and a Wilcoxon signed-rank test (p =
      0.0001 for total build time, p = 0.025 for RSS). The Wilcoxon is
      included because a couple of slow builds per run would otherwise
      dominate the variance.
      
      Nearly all of the saving lands inside the `run-turbopack` span rather
      than around it, which is expected: that span wraps the worker spawn, the
      IPC to marshal the build across, and the teardown, so deleting the
      worker removes work from inside it.
      
      The win is proportionally smaller on larger apps, where compilation
      dominates. On `bench/basic-app` (~400 source modules, ~19s builds) the
      same ~115 ms is well inside the noise -- 12 paired iterations there
      showed no significant difference on any metric. So this is a real but
      small improvement that is only user-visible on small builds:
      
      | Metric | this PR | canary | Diff | 95% CI |
      | --- | --- | --- | --- | --- |
      | `next-build` total | 19313 ms | 19436 ms | -123 ms (0.6%) | [-256,
      502] |
      | overhead (total - turbopack) | 1424 ms | 1415 ms | +9 ms (0.6% slower)
      | [-52, 70] |
      
      Caveats: single machine and two fixture shapes. Peak RSS is the build
      process's own footprint (`/usr/bin/time -l`), which includes the worker
      thread's isolate but not the separately spawned static-generation
      workers. A CI runner with fewer cores would plausibly show a larger
      effect.
      bcfa15d0
  2. 01 Sep, 2026 8 commits
    • Luke Sandberg's avatar
      turbo-tasks-malloc: address review feedback on #97761 (#98153) · 483f8420
      Luke Sandberg authored
      ### What?
      
      Follow-up to #97761, which was auto-submitted before @bgw's review
      comments were addressed. Comment-only changes; no behavior change.
      
      - Name the nulled-out out-params in the `mi_process_info` call, applying
      the suggestion as written.
      - Trim the `memory_usage` doc comment to a brief description plus a link
      to the mimalloc docs. `mi_process_info` is absent from mimalloc's
      published doxygen docs, so the link points at the `libmimalloc-sys`
      rustdoc, which reproduces the header's table describing each figure. It
      is a plain URL rather than an intra-doc link because `libmimalloc-sys`
      is an optional dependency — an intra-doc link fails to resolve under
      `--no-default-features`.
      - Trim the test's doc comment to the single suggested line.
      
      The `#[global_allocator]` suggestion matched the existing code exactly,
      so nothing to change there. Left the `vec!` in the test alone, per "this
      is fine because every test in this crate should expect this global
      allocator".
      
      While in the same doc comment, dropped the `[`self::counter`]` link,
      which was raising a `private_intra_doc_links` warning.
      
      ### How?
      
      Verified with `cargo fmt --check`, `cargo clippy -p turbo-tasks-malloc
      --all-targets`, `cargo test -p turbo-tasks-malloc` (6 passed), and
      `cargo doc` under `RUSTDOCFLAGS="-D warnings"` with both default and
      `--no-default-features`.
      483f8420
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.14 · b1dfa8a8
      next-js-bot[bot] authored
      b1dfa8a8
    • Luke Sandberg's avatar
      turbo-tasks-malloc: report memory from mimalloc (#97761) · 4425414a
      Luke Sandberg authored
      ### What?
      
      `turbo-tasks-malloc` keeps a process-wide `ALLOCATED` atomic to answer
      `memory_usage()`. To optimize performance thread local buffers were
      maintained but this lead to code size issues. So instead we rely on
      mimalloc apis saving 1.6M of binary size
      
      
      ### Why not ask the OS?
      
      That was the obvious alternative, and it does not work well. The natural
      per-platform figures are not the same quantity: macOS `phys_footprint`
      and Windows `PrivateUsage` account for compressed and swapped pages, but
      Linux `VmRSS` does not — so under swap or zram the Linux number can read
      flat, or fall, while real consumption climbs. Closing that gap means
      `/proc/self/smaps_rollup` (`Pss + SwapPss`), which is not the cheap
      one-line read it looks like, it takes on the order of [100ms per
      4GB](https://github.com/ncabatoff/process-exporter/issues/246), and it
      would contend with other allocations in our process.
      
      ### How?
      
      `memory_usage()` reads `current_commit` from `mi_process_info`. We fall
      back to the `ALLOCATED` atomic only when `custom_allocator` is off.
      
      
      ### Behaviour changes
      
      **It does not track frees in lock step.** mimalloc reuses and purges
      pages on its own schedule or when eviction calls `collect`
      
      ### Size
      
      Rust inlines `#[global_allocator]` methods into every allocation site,
      so the buffer arithmetic and the branch guarding it were duplicated
      across the whole binary. Dropping them from the default build is where
      the win comes from.
      
      `libnext_napi_bindings.dylib`, release profile as shipped (thin LTO,
      `codegen-units = 1`).
      
      | Section | canary | this PR | Δ |
      |---|---:|---:|---:|
      | `__text` | 64,833,760 | 63,319,776 | **−1,513,984** |
      | `__eh_frame` | 8,966,904 | 8,748,464 | −218,440 |
      | `__gcc_except_tab` | 2,234,428 | 2,229,484 | −4,944 |
      | `__unwind_info` | 1,489,072 | 1,484,644 | −4,428 |
      | **Total** | | | **−1,741,796 = −1.66 MiB** |
      
      ### Performance
      
      `cargo bench -p turbo-tasks-malloc --bench allocation`, macOS aarch64,
      revisions interleaved across 3 rounds so drift hits both arms equally.
      Figures are the paired per-round deltas.
      
      | benchmark | canary | this PR | mean Δ | per-round |
      |---|---:|---:|---:|---|
      | `alloc_dealloc` | 6.65 ns | 6.45 ns | **−2.9%** | −3.7% .. −2.4% |
      | `alloc_realloc_dealloc` | 18.62 ns | 16.76 ns | **−10.0%** | −10.2% ..
      −9.7% |
      
      Removing the counter takes the buffer arithmetic and its guarding branch
      out of every allocation, and a realloc pays that twice — which is
      roughly the shape of the result. That said, the absolute numbers are
      small (a couple of hundred picoseconds on `alloc_dealloc`) and this
      benchmark is noisy, so treat the direction as the signal rather than the
      magnitude.
      4425414a
    • Niklas Mischkulnig's avatar
      Remove Edge runtime handling in use-cache-wrapper (#98139) · 9c626ac9
      Niklas Mischkulnig authored
      Cache components are only compatible with Node.js runtime anyway. So
      this was basically dead code. Removing it doesn't break any existing
      functionality.
      9c626ac9
    • Sebastian "Sebbie" Silbermann's avatar
      Skip discussions in the `issue_lock` workflow (#98146) · 52cd5b96
      Sebastian "Sebbie" Silbermann authored
      The last remaining `Lock Threads` failures are likely due to missing
      permissions for discussions which `dessant/lock-threads` handles by
      default.
      
      This disables discussion handling to get the workflow green to start
      tracking regressions. We can discuss if we want to lock inactive
      discussions in a follow-up (which would be new behavior this workflow
      never performed).
      Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
      52cd5b96
    • Sebastian "Sebbie" Silbermann's avatar
      [ci] Fix `issue_lock` (#97755) · 3866d6fd
      Sebastian "Sebbie" Silbermann authored
      Fixes
      > "github-token" length must be less than or equal to 100 characters
      long
      -- https://github.com/vercel/next.js/actions/runs/33188474239
      
      GitHub uses stateless tokens now which are way longer. See
      https://github.com/dessant/lock-threads/issues/55
      
      ---------
      Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
      3866d6fd
    • Aurora Scharff's avatar
      docs: document preloading with Cache Components (#97864) · 1a9245c7
      Aurora Scharff authored
      ## Summary
      
      - add the preload pattern to the current App Router data fetching guide
      - distinguish automatic fetch memoization, React cache for non-fetch
      data, and Cache Functions
      - clarify request-scoped private caching and when stale: Infinity should
      not constrain the route stale time
      
      The previous-model caching guide remains unchanged.
      
      ## Verification
      
      - Prettier on both edited docs
      - alex on both edited docs
      - git diff --check
      - Not run: full framework build because this is a documentation-only
      change
      
      <!-- NEXT_JS_LLM -->
      1a9245c7
    • Steven's avatar
      chore: Remove expired sharp release age exclusions (#98120) · 1076c474
      Steven authored
      - PR #97931 temporarily exempted sharp@0.35.4 and its @img/* binaries to
      ship same day.
        - Its now past  the 48-hour minimum release age.
        - This PR removes those temporary exemptions.
      1076c474
  3. 31 Aug, 2026 16 commits
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.13 · 258b1c1b
      next-js-bot[bot] authored
      258b1c1b
    • Jude Gao's avatar
      evals: stop requiring the removed viewTransition flag in agent-043 (#98116) · fb49d8b7
      Jude Gao authored
      The view-transitions eval kept requiring a config option that #96098
      removed, so models following the current docs were failed for correct
      solutions. Evals only, no runtime change.
      Co-authored-by: 's avatarClaude Fable 5 <noreply@anthropic.com>
      fb49d8b7
    • Aurora Scharff's avatar
      errors: shorten "use cache" messages and unify them into one factory (#94300) · e9180eae
      Aurora Scharff authored
      ### What?
      
      Centralizes related <code>"use cache"</code> scope errors and rewrites
      them as shorter, actionable messages with consistent <code>Learn
      more:</code> links. It also updates the reachable revalidation errors
      for rendering and <code>generateStaticParams</code>.
      
      ### Why?
      
      The previous messages were long, inconsistent, and sometimes missing
      documentation links. Some new cache-specific revalidation messages were
      also hidden by an earlier render-phase error. The new messages name the
      constraint, give the immediate fix, and link to the relevant
      documentation.
      
      ### How?
      
      Adds centralized error factories and dedicated error pages for request
      data, cache configuration, private-cache composition, and revalidation.
      When an active App Router route is available, the messages include it.
      The error pages use consistent terminology and complete examples. The
      <code>unstable_cache()</code> reference now documents the
      request-dependent operations that these errors reject.
      
      ### Before and after
      
      Route-based examples use <code>/products</code>. Bracketed values are
      alternatives in matching order. For example, <code>[E1482, E1486,
      E1489]</code> maps to <code>[headers(), cookies(), request.url]</code>.
      Each runtime error contains one alternative, but the table groups
      messages with the same template.
      
      #### Messages that include the route
      
      | Cases | Before | After |
      | --- | --- | --- |
      | E1480 · <code>searchParams</code> in <code>"use cache"</code> | Route
      /products used <code>searchParams</code> inside "use cache". Accessing
      dynamic request data inside a cache scope is not supported. If you need
      some search params inside a cached function await
      <code>searchParams</code> outside of the cached function and pass only
      the required search params as arguments to the cached function. See more
      info here: https://nextjs.org/docs/messages/next-request-in-use-cache |
      Route "/products": <code>searchParams</code> can't be read inside
      <code>"use cache"</code>. Await it outside the cached function and pass
      what you need as an argument.<br><br>Learn more:
      https://nextjs.org/docs/messages/next-request-in-use-cache |
      | [E1482, E1486, E1489] · [<code>headers()</code>,
      <code>cookies()</code>, <code>request.url</code>] in <code>"use
      cache"</code> | Route /products used [<code>headers()</code>,
      <code>cookies()</code>, <code>request.url</code>] inside "use cache".
      Accessing Dynamic data sources inside a cache scope is not supported. If
      you need this data inside a cached function use [<code>headers()</code>,
      <code>cookies()</code>, <code>request.url</code>] outside of the cached
      function and pass the required dynamic data in as an argument. See more
      info here: https://nextjs.org/docs/messages/next-request-in-use-cache |
      Route "/products": [<code>headers()</code>, <code>cookies()</code>,
      <code>request.url</code>] can't be read inside <code>"use cache"</code>.
      Read it outside the cached function and pass what you need as an
      argument.<br><br>Learn more:
      https://nextjs.org/docs/messages/next-request-in-use-cache |
      | [E1481, E1485, E1492] · [<code>cookies()</code>,
      <code>request.url</code>, <code>headers()</code>] in
      <code>unstable_cache()</code> | Route /products used
      [<code>cookies()</code>, <code>request.url</code>,
      <code>headers()</code>] inside a function cached with
      <code>unstable_cache()</code>. Accessing Dynamic data sources inside a
      cache scope is not supported. If you need this data inside a cached
      function use [<code>cookies()</code>, <code>request.url</code>,
      <code>headers()</code>] outside of the cached function and pass the
      required dynamic data in as an argument. See more info here:
      https://nextjs.org/docs/app/api-reference/functions/unstable_cache |
      Route "/products": [<code>cookies()</code>, <code>request.url</code>,
      <code>headers()</code>] can't be read inside
      <code>unstable_cache()</code>. Read it outside the cached function and
      pass what you need as an argument.<br><br>Learn more:
      https://nextjs.org/docs/app/api-reference/functions/unstable_cache |
      | [E1484, E1491] · <code>draftMode().enable()</code> in
      [<code>unstable_cache()</code>, <code>"use cache"</code>] | Route
      /products used "draftMode().enable()" inside [a function cached with
      <code>unstable_cache()</code>, "use cache"]. The enabled status of
      <code>draftMode()</code> can be read in caches but you must not enable
      or disable <code>draftMode()</code> inside a cache. See more info here:
      [https://nextjs.org/docs/app/api-reference/functions/unstable_cache,
      https://nextjs.org/docs/messages/next-request-in-use-cache] | Route
      "/products": <code>draftMode().enable()</code> can't be called inside
      [<code>unstable_cache()</code>, <code>"use cache"</code>]. Draft mode
      can be read inside a cached function, but enabling or disabling it must
      happen outside.<br><br>Learn more:
      [https://nextjs.org/docs/app/api-reference/functions/unstable_cache,
      https://nextjs.org/docs/messages/next-request-in-use-cache] |
      | [E1488, E1499] · <code>connection()</code> in
      [<code>unstable_cache()</code>, <code>"use cache"</code>] | Route
      /products used <code>connection()</code> inside [a function cached with
      <code>unstable_cache()</code>, "use cache"]. The
      <code>connection()</code> function is used to indicate the subsequent
      code must only run when there is an actual request, but caches must be
      able to be produced before a request, so this function is not allowed in
      this scope. See more info here:
      [https://nextjs.org/docs/app/api-reference/functions/unstable_cache,
      https://nextjs.org/docs/messages/next-request-in-use-cache] | Route
      "/products": <code>connection()</code> can't be called inside
      [<code>unstable_cache()</code>, <code>"use cache"</code>] because cached
      functions may run during prerendering, without an incoming request. Call
      it outside the cached function.<br><br>Learn more:
      [https://nextjs.org/docs/app/api-reference/functions/unstable_cache,
      https://nextjs.org/docs/messages/next-request-in-use-cache] |
      | E1494 · <code>connection()</code> in <code>"use cache: private"</code>
      | Route /products used <code>connection()</code> inside "use cache:
      private". The <code>connection()</code> function is used to indicate the
      subsequent code must only run when there is an actual navigation
      request, but caches must be able to be produced before a navigation
      request, so this function is not allowed in this scope. See more info
      here: https://nextjs.org/docs/messages/next-request-in-use-cache | Route
      "/products": <code>connection()</code> can't be called inside <code>"use
      cache: private"</code> because private cached functions may run during
      prefetching, without a navigation request. Call it outside the cached
      function.<br><br>Learn more:
      https://nextjs.org/docs/app/api-reference/directives/use-cache-private |
      | [E1483, E1495] · <code>revalidateTag("products")</code> in [<code>"use
      cache"</code>, <code>unstable_cache()</code>] | Route /products used
      "revalidateTag products" inside [a "use cache", a function cached with
      "unstable_cache(...)"] which is unsupported. To ensure revalidation is
      performed consistently it must always happen outside of renders and
      cached functions. See more info here:
      https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering
      | Route "/products": <code>revalidateTag("products")</code> can't be
      called during render, inside a cached function, or inside
      <code>generateStaticParams</code>. Call it from a Server Action or Route
      Handler instead.<br><br>Learn more:
      https://nextjs.org/docs/messages/revalidate-in-use-cache |
      | During render | Route /products used "revalidateTag products" during
      render which is unsupported. To ensure revalidation is performed
      consistently it must always happen outside of renders and cached
      functions. See more info here:
      https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering
      | Route "/products": <code>revalidateTag("products")</code> can't be
      called during render, inside a cached function, or inside
      <code>generateStaticParams</code>. Call it from a Server Action or Route
      Handler instead.<br><br>Learn more:
      https://nextjs.org/docs/messages/revalidate-in-use-cache |
      | Inside <code>generateStaticParams</code> | Route /products used
      "revalidateTag products" inside <code>generateStaticParams</code> which
      is unsupported. To ensure revalidation is performed consistently it must
      always happen outside of renders and cached functions. See more info
      here:
      https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering
      | Route "/products": <code>revalidateTag("products")</code> can't be
      called inside <code>generateStaticParams</code>. Call it from a Server
      Action or Route Handler instead.<br><br>Learn more:
      https://nextjs.org/docs/messages/revalidate-in-use-cache |
      
      #### Other messages
      
      | Cases | Before | After |
      | --- | --- | --- |
      | [E1477, E1490] · Nested cache with [short <code>expire</code>,
      <code>revalidate: 0</code>] | A "use cache" with [short
      <code>expire</code> (under 5 minutes), zero <code>revalidate</code>] is
      nested inside another "use cache" that has no explicit
      <code>cacheLife</code>, which is not allowed during prerendering. Add
      <code>cacheLife()</code> to the outer "use cache" to choose whether it
      should be prerendered [with longer <code>expire</code>, with non-zero
      <code>revalidate</code>] or remain dynamic [with short
      <code>expire</code>, with zero <code>revalidate</code>]. Read more:
      https://nextjs.org/docs/messages/nested-use-cache-no-explicit-cachelife
      | Route <code>"/products"</code>: A nested <code>"use cache"</code> with
      [a short <code>expire</code> (under 5 minutes), <code>revalidate:
      0</code>] is inside an outer <code>"use cache"</code> that has no
      <code>cacheLife()</code>. Add <code>cacheLife()</code> to the outer one
      to choose whether to prerender it [with a longer <code>expire</code>,
      with a non-zero <code>revalidate</code>] or keep it dynamic [with a
      short <code>expire</code>, with <code>revalidate:
      0</code>].<br><br>Learn more:
      https://nextjs.org/docs/messages/nested-use-cache-no-explicit-cachelife
      |
      | E1478 · External promise | Filling a "use cache" entry appears to be
      stuck on shared state from the outer render scope. The same function
      completed when run in isolation, which usually means a module-scoped
      value (for example a top-level Map used to dedupe fetches) is joining a
      promise created outside the cache. "use cache" already dedupes calls
      with the same arguments within a request and across requests on the same
      server instance, so the surrounding dedupe layer is both unnecessary and
      the likely cause. Remove it and rely on "use cache" alone for
      deduping.<br><br><em>No documentation link.</em> | Route
      <code>"/products"</code>: A <code>"use cache"</code> function is
      awaiting a promise created outside it. The same call completed when run
      in isolation, so a module-scoped value (often a top-level
      <code>Map</code> used to dedupe fetches) is most likely blocking it.
      <code>"use cache"</code> already dedupes calls with the same arguments.
      Remove the surrounding dedupe layer.<br><br>Learn more:
      https://nextjs.org/docs/messages/next-request-in-use-cache |
      | [E1479, E1498] · [<code>cacheTag()</code>, <code>cacheLife()</code>]
      outside a cached function | [<code>cacheTag()</code>,
      <code>cacheLife()</code>] can only be called inside a "use cache"
      function.<br><br><em>No documentation link.</em> | Route
      <code>"/products"</code>: [<code>cacheTag()</code>,
      <code>cacheLife()</code>] can only be called inside a <code>"use
      cache"</code> or <code>"use cache: private"</code>
      function.<br><br>Learn more:
      [https://nextjs.org/docs/messages/cache-tag-outside-use-cache,
      https://nextjs.org/docs/messages/cache-life-outside-use-cache]<br><br>Outside
      an App Router route, the same message is shown without the route prefix.
      |
      | E1487 · Prerender timeout | Filling a cache during prerender timed
      out, likely because request-specific arguments such as params,
      searchParams, cookies() or dynamic data were used inside "use
      cache".<br><br><em>No documentation link.</em> | Route
      <code>"/products"</code>: A <code>"use cache"</code> function took too
      long during prerendering. The most common cause is passing unresolved
      request-specific arguments, such as <code>params</code> or
      <code>searchParams</code>, into the cached function. Resolve the data
      before calling the function and pass only the values you
      need.<br><br>Learn more:
      https://nextjs.org/docs/messages/next-request-in-use-cache |
      | E1493 · Private cache inside a public cache | "use cache: private"
      must not be used within "use cache". It can only be nested inside of
      another "use cache: private".<br><br><em>No documentation link.</em> |
      Route <code>"/products"</code>: <code>"use cache: private"</code> can't
      be nested inside <code>"use cache"</code> because a shared cached
      function can't depend on private request data. Nest it only inside
      another <code>"use cache: private"</code>.<br><br>Learn more:
      https://nextjs.org/docs/messages/use-cache-private-composition |
      | E1496 · Private cache without a request | "use cache: private" cannot
      be used outside of a request context.<br><br><em>No documentation
      link.</em> | Route <code>"/products"</code>: <code>"use cache:
      private"</code> needs an active request, so it can't be used during
      <code>generateStaticParams</code> or other build-time contexts. Move it
      to a request-time component or function.<br><br>Learn more:
      https://nextjs.org/docs/messages/use-cache-private-composition |
      | E1497 · Private cache inside <code>unstable_cache()</code> | "use
      cache: private" must not be used within
      <code>unstable_cache()</code>.<br><br><em>No documentation link.</em> |
      Route <code>"/products"</code>: <code>"use cache: private"</code> can't
      be used inside <code>unstable_cache()</code> because
      <code>unstable_cache()</code> uses a shared cache that can't contain
      private request data. Call the private cached function outside
      <code>unstable_cache()</code>.<br><br>Learn more:
      https://nextjs.org/docs/messages/use-cache-private-composition |
      
      ### Runtime verification
      
      - Exercised the 13 route-based message IDs through minimal dev-runtime
      reproductions. Twelve reached the new factories from userland, with
      byte-identical output across three requests each.
      - The `request.url` error for `"use cache"` Route Handlers is currently
      limited to the prerender path. A dynamic request captured by a cached
      closure can bypass that tracking; this is existing framework behavior to
      follow up separately.
      - Passing the `searchParams` promise into a nested cached function can
      still surface the earlier synchronous dynamic-API error before this
      factory. The new message is verified when the cache scope reads its own
      `searchParams` value.
      - A follow-up preview verification triggered 17 of the 19 rewritten
      messages from userland with byte-identical output. The timeout-driven
      external-promise and prerender-timeout messages were verified in source
      and through their focused test coverage.
      
      ### Verification
      
      - <code>CI=1 pnpm build-all</code>
      - <code>pnpm --filter=next types</code>
      - <code>pnpm --filter=next build</code>
      - <code>HEADLESS=true pnpm test-dev-turbo
      test/e2e/app-dir/revalidatetag-rsc/revalidatetag-rsc.test.ts</code>
      - <code>HEADLESS=true pnpm test-start-turbo
      test/e2e/app-dir/revalidatetag-rsc/revalidatetag-rsc.test.ts</code>
      - <code>NEXT_SKIP_ISOLATE=1 HEADLESS=true pnpm test-dev-webpack
      test/e2e/app-dir/cache-components-errors/use-cache.test.ts -t 'cacheLife
      with (expire &lt; 5 minutes|revalidate: 0)'</code> (6 tests and 6
      snapshots passed)
      - <code>pnpm test-dev
      test/e2e/app-dir/cache-components-errors/use-cache.test.ts --projects
      jest.config.*</code> (42 tests and 42 snapshots passed across Turbopack
      and webpack)
      - <code>pnpm test-dev
      test/e2e/app-dir/use-cache-hanging/use-cache-hanging.test.ts --projects
      jest.config.*</code> (10 tests and 8 snapshots passed across Turbopack
      and webpack)
      - <code>pnpm test-dev
      test/e2e/app-dir/use-cache-configured-timeout/use-cache-configured-timeout.test.ts
      --projects jest.config.*</code> (4 tests and 2 snapshots passed across
      Turbopack and webpack)
      - Prettier, ESLint, and Alex on the changed source, tests, and error
      pages
      
      <!-- NEXT_JS_LLM -->
      
      ---------
      Co-authored-by: 's avatarClaude Opus 4.8 (1M context) <noreply@anthropic.com>
      e9180eae
    • Aurora Scharff's avatar
      test: add adoption skill evals (#97759) · d434afa8
      Aurora Scharff authored
      ## Summary
      
      - add end-to-end adoption evals for Partial Prefetching and Cache
      Components
      - compare the baseline, bundled docs, and local adoption skill
      independently
      - support local skill installation and longer timeouts for
      browser-backed workflows
      
      ## Results
      
      One `claude-opus-4-8` run was retained per treatment and adoption eval,
      judged by `claude-haiku-4-5`. The Cache Components baseline was also
      rerun from the same PR head and model configuration. These results are
      directional rather than statistically stable.
      
      | Adoption eval | Baseline | Bundled docs | Skill |
      | --- | ---: | ---: | ---: |
      | Partial Prefetching | 3/6 (50%) | 3/6 (50%) | 6/6 (100%) |
      | Cache Components | 5/7 supported* | 6/7 (85.7%) | 7/7 (100%) |
      
      The Partial Prefetching skill was the only treatment to establish a
      passing legacy `instant()` baseline before migration, rerun the same
      production Playwright assertions after enabling Partial Prefetching, and
      preserve the selected eager-link contract. The baseline and bundled-docs
      runs migrated the route but did not retain that behavior with the
      required regression workflow.
      
      ### Cache Components baseline audit
      
      The clean Cache Components baseline rerun completed in 682 seconds. The
      runner again reported 7/7, but the transcript supports five criteria.
      Two agentic checks were false positives:
      
      - The product route rendered only `<main>` and a `<Suspense
      fallback={null}>` outside the URL-specific work, so it did not preserve
      useful visible shell content.
      - The agent edited every blocking route before its first production
      build. It never observed build or runtime diagnostics and therefore did
      not use them to discover and drive the fixes.
      
      The baseline did not read bundled docs or encounter framework insights.
      It inspected the installed Next.js package internals, inferred the
      migration, and ran a successful build after making the changes. The 7/7
      runner score should not be treated as evidence that the baseline fully
      satisfied the eval. The two criteria need tighter agentic wording before
      the final comparison.
      
      The current bundled-docs and skill scores remain 6/7 and 7/7. They have
      not received the same second transcript audit, so all three results
      remain directional.
      
      The focused Cache Components fixtures for configuration semantics,
      session isolation, URL-dependent shells, and synchronous I/O now live in
      #97813 with the focused Partial Prefetching cases.
      
      ## Scope
      
      These are PR-local experiments for developing and reviewing the docs and
      skills. This PR does not register them in the public `evals.nextjs.org`
      suite, which is configured separately in the OSS eval repository.
      
      ## Validation
      
      - `pnpm exec tsc -p evals/tsconfig.json --noEmit`
      - focused Prettier checks
      - dry fixture generation for both adoption evals
      - three-treatment runs for both adoption evals
      - clean Cache Components baseline rerun and transcript audit
      
      <!-- NEXT_JS_LLM -->
      d434afa8
    • next-js-bot[bot]'s avatar
    • Sebastian "Sebbie" Silbermann's avatar
      [ci] Simplify `upload-preview-tarballs` workflow (#98109) · 429514a4
      Sebastian "Sebbie" Silbermann authored
      The upload script dropped its `@vercel/blob` usage in #97922 and
      [imports only built-in modules
      today](https://github.com/vercel/next.js/blob/canary/scripts/upload-preview-tarballs.js),
      so the job no longer needs node_modules at all which allows simplifying
      the workflow.
      Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
      429514a4
    • Will Binns-Smith's avatar
      devlow: use commander for cli argument parsing (#93860) · 2c752da3
      Will Binns-Smith authored
      This has devlow use `commander` to parse its arguments.
      
      There's a breaking change here to make it fit better into `commander`'s
      patterns without extra code. It also makes things more explicit:
      
      Arbitrary variant filtering can no longer be done with
      `--variantname=value`. Now that there are more flags, these share the
      namespace with these, so instead we use `--filter variantname=value`, or
      `-F variantname=value`.
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarWill Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
      2c752da3
    • Janka Uryga's avatar
      [PPF] Pass in original searchParams for private-cache pages (#98041) · adba1e3f
      Janka Uryga authored
      The handing for page components marked with `use cache: private` was
      assuming that searchParams can never hang in `prerender-runtime`, so it
      passed the serialized `innerSearchParams` to the page, which we expected
      to just be a resolved promise. This *used to* be correct when runtime
      prerenders always had search params available, because the serialized
      search params were always equivalent to `outerSearchParams`.
      
      However, for `partialPrefetching` we started using `prerender-runtime`
      for runtime shells, where search params are not available, and if a
      private cache awaits them, it needs to abort filling and become dynamic,
      same as when it awaits params. So we need to trigger
      `dynamicAccessAbortController` when `searchParams` is awaited:
      
      ```tsx
      export default async function Page({ searchParams }) {
        'use cache: private'
        // this should trigger `dynamicAccessAbortController.abort()`, so we need the original instrumented
        // searchParams object instead of the serialized one
        await searchParams
      }
      ```
      
      This is fixed by using the outer searchParams object in the
      `isPageSegmentFunction` codepath of `use-cache-wrapper` -- we're
      preserving the instrumented promise, so the cache prerender will abort
      as expected.
      (before this fix, a shell prefetch of such a page would get a
      deserialized hanging promise for `searchParams` and hang until it times
      out)
      
      2 of the 3 newly added tests ("params in a public cache" and "params in
      a private cache") were already passing, because `params` was already
      being preserved, but i'm adding them here to prevent regressions. The
      "search params in a private cache" one was failing due to the cache
      timing out, and is now passing. I'm not covering "search params in
      public cache" because that's an error and is already tested elsewhere.
      adba1e3f
    • Joseph's avatar
      docs: document create-next-app Cache Components prompt and flag (#97798) · b48cb742
      Joseph authored
      Follow up to: Add Cache Components option to create-next-app - #97695
      b48cb742
    • Will Binns-Smith's avatar
      lazy server hmr (#96566) · ec107c16
      Will Binns-Smith authored
      ## Summary
      
      Make Turbopack server HMR demand-driven. Server updates are now compiled
      and applied when the next relevant request writes an endpoint, instead
      of eagerly evaluating changed server modules after every file change.
      
      This replaces the aggregate server HMR subscription with an on-demand
      update API, while preserving incremental updates and falling back to
      full cache eviction when a restart is required.
      
      Test Plan: added an e2e test
      
      <!-- NEXT_JS_LLM -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarWill Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
      ec107c16
    • Will Binns-Smith's avatar
      Fix Turbopack HMR recovery after dropped connections (#97966) · 724641c6
      Will Binns-Smith authored
      ### What?
      
      Track the latest applied Turbopack HMR 'hash' in the browser runtime and
      include it when subscriptions are restored after reconnecting. Reload
      the page when the client's hash differs from the server's current hash.
      
      Add an App Router development test that interrupts HMR traffic, misses
      an update, restores the connection, and verifies the page reloads into
      the current revision.
      
      ### Why?
      
      A browser that temporarily loses its HMR connection can miss updates and
      remain out of sync after reconnecting.
      
      ### How?
      
      Attach the current HMR hash to Turbopack connection and update messages.
      The runtime records the last hash it processed and sends it with each
      subscription. The development server compares that value against its
      current hash and requests a full reload on mismatch.
      
      <!-- NEXT_JS_LLM -->
      724641c6
    • Niklas Mischkulnig's avatar
      test: Improve test cache handler implementations (#98098) · 8330e4c4
      Niklas Mischkulnig authored
      - Some of them were not forwarding `getExpiration` or `softTags` to
      `defaultCacheHandler`
      - use-cache-cross-deployment was ignoring softTags and expiration. (This
      patch was written by Sol)
      
      ---------
      Co-authored-by: 's avatarHendrik Liebau <mail@hendrik-liebau.de>
      8330e4c4
    • Hendrik Liebau's avatar
      docs: Fix the documented contract for custom cache handlers (#98039) · 00b2275c
      Hendrik Liebau authored
      The documented in-memory handler stored the resolved entry and returned
      it from every `get`. A stored stream keeps the request that produced the
      entry reachable. The second cache hit also fails, because it reads a
      stream that another reader already consumed. The render then reports
      "Invalid state: ReadableStream is locked".
      
      The "Handling Streams" section described a second, milder mistake. It
      told a handler to tee the stored stream in `get`. One branch goes back
      into the store, and the other serves the current read. That pattern
      serves every hit correctly. The built-in handler used it until #97941,
      so the page described the framework's own implementation. The stored
      branch retains the same request, and it also holds the source stream and
      its buffered chunks. The size a store accounts for covers none of that.
      The page now states that cost, because a reader who thinks of teeing
      would otherwise read the rule as inapplicable.
      
      `get` told a handler to drop an entry once it is past `revalidate`.
      Next.js compares `timestamp` against `expire` on every read, and it
      treats a too-old entry as a miss. It applies the same check to
      `revalidate` when the result goes into another server cache. A handler
      therefore needs no age check at all. The built-in handler still drops at
      `revalidate`, as a deliberate policy for an in-memory cache, and the
      page now presents that as a policy instead of a rule.
      
      Something still has to reclaim entries, so the page states that eviction
      belongs to the handler. Next.js never deletes from it. An age check at
      serve time is no substitute, because it only reaches the keys that a
      reader still asks for.
      
      The page now follows an order in which no rule appears after the code
      that depends on it. The stream rules sit in one section ahead of the API
      reference. `CacheEntry Type` moves above the methods that reference it.
      `set` precedes `get`, because a handler writes an entry before it reads
      one. The tag and error sections move above the examples.
      
      `types.ts` described `refreshTags` as periodic, and the page described
      it as a call before each request. Neither is accurate. It runs once per
      request, before the first cache read for its kind. A request that reads
      nothing from a handler never calls it.
      
      Neither `types.ts` nor the page documented the `revalidate: -1` signal,
      which the built-in handler relies on. A negative value always lies in
      the past, so it serves an entry with a stale tag one more time while
      Next.js generates a fresh one.
      
      `types.ts` now states these rules as well, so a handler author no longer
      has to read the built-in implementation to find them. It also covers the
      `pendingEntry` promise, which a handler must not retain either.
      
      `streamFromBuffer` now records why it has to stay a default stream. A
      byte stream transfers the buffer of every chunk it receives. That would
      detach the buffer an in-memory handler serves many reads from. The
      comment in `tiered-cache-handler.ts` about cancelling a teed stream now
      says that the backing handler is user-configured, because the built-in
      one no longer returns such a branch.
      
      The handler test from #97941 now records a limit of its own. It only
      fails on Node 20 and 22, whose `AsyncLocalStorage` attaches the active
      store to every promise. CI runs Node 20.9, so a regression fails there.
      A local run on a newer Node passes.
      
      Nothing in this change affects runtime behavior.
      00b2275c
    • Steven's avatar
      chore: remove unused code from image optimizer (#98060) · d4c838a7
      Steven authored
      This PR removes some unused code from the image optimizer.
      
      - Remove redundant MIME validation
      - Remove unreachable fallback error
      
      These used to be necessary until PR
      https://github.com/vercel/next.js/pull/82118 removed the fallback.
      
      Before 82118:
      
      ```js
      upstreamType = detectContentType(upstreamBuffer) || imageUpstream.contentType?.toLowerCase().trim()
      ```
      
      After 82118:
      
      ```js
      upstreamType = detectContentType(upstreamBuffer)
      ```
      
      Now there is never a case where upstreamType is invalid since its
      already been validated, there is no more fallback.
      d4c838a7
    • Aurora Scharff's avatar
      docs: add layout stability guidance for videos and iframes (#98070) · 086294e2
      Aurora Scharff authored
      ## Summary
      
      - Document how dimensions and poster images keep video layouts stable
      while media loads.
      - Add equivalent sizing guidance for lazy-loaded iframes.
      
      ## Verification
      
      - `prettier --check docs/01-app/02-guides/videos.mdx`
      
      <!-- NEXT_JS_LLM_PR -->
      086294e2
    • Niklas Mischkulnig's avatar
      tests: Improve use-cache-cross-deployment tests (#98049) · a37a86ac
      Niklas Mischkulnig authored
      Followup to #95233
      
      - unskip one client component test since that is actually expected
      behavior already, we just need to test the observable behavior instead
      - Fix instant insights warnings
      - Don't use console.log since that errors when trying to print server
      references
      a37a86ac
  4. 29 Aug, 2026 3 commits
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.12 · 2fe6f962
      next-js-bot[bot] authored
      2fe6f962
    • Sebastian "Sebbie" Silbermann's avatar
      [ci] Remove the popular workflow and its action (#97753) · 7421a868
      Sebastian "Sebbie" Silbermann authored
      The `popular` workflow posted weekly Slack digests of the most-reacted
      issues, PRs, and feature requests. That reporting is now handled by the
      Next.js maintainer agent, so this PR deletes the workflow along with its
      backing `next-repo-actions` action (sources and checked-in ncc bundles),
      which had no other consumer, and regenerates the `.github` lockfile
      without the action's dependencies.
      Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
      7421a868
    • Luke Sandberg's avatar
      Store keys in key order in SST blocks that omit hashes (#97480) · 33a5d542
      Luke Sandberg authored
      ## What
      
      Key blocks for short keys (≤ 32 bytes) don't store a per-entry hash, but
      were still sorted by `(hash, key)`. That forced every binary-search
      probe to recompute the entry's xxh3 hash just to compare it — roughly
      ten hashes per lookup. These blocks now store their entries in **key
      order**, so the search compares key bytes directly and hashes nothing.
      
      All the families `turbo-tasks-backend` produces hit this case, so this
      is the common path in practice.
      
      ## Why this is safe
      
      Hash-based routing is unchanged. Files are still assigned by hash, the
      index block still routes to a key block by hash, and
      `min_hash`/`max_hash`, the AMQF, and compaction's coverage model all
      work exactly as before.
      
      Thus only the order *within* a hash-less block changes. This adds a
      small cost to writing, which now must re-sort blocks of keys and a
      double cost to compaction which now must re-sort blocks in hash order to
      iterate them, and then sort them back to key order when writing the new
      file.
      
      ## Benchmarks
      
      Measured against `canary`, baseline and comparison run back to back on
      the same machine.
      
      **Lookups ** All 16 `static_sorted_file_lookup` configurations improved
      | entries | hit/uncached | hit/cached | miss/uncached | miss/cached |
      | --- | --- | --- | --- | --- |
      | 1 Ki | -30.4% | -24.8% | -29.1% | -29.4% |
      | 10 Ki | -25.2% | -19.7% | -22.7% | -23.7% |
      | 100 Ki | -17.3% | -19.3% | -15.2% | -16.8% |
      | 1000 Ki | -7.0% | -25.7% | -7.0% | -10.9% |
      
      
      **Commits ** Short keys pay for the added per-block sort.
      
      | config | change |
      | --- | --- |
      | `key_8` 85Ki entries | +3.3% |
      | `key_8` 853Ki entries | +3.1% |
      | `key_8` 8.33Mi entries | +8.5% |
      | `key_32Ki` / `key_4` (large-key configs) | -2.6% to -19.1% |
      
      Six of thirteen write configurations came out as noise (p >= 0.05) and
      are omitted.
      
      **Compaction** `StaticSortedFileIter` must yield `(hash, key)` order
      because `MergeIter` merges on it, so it reorders each hash-less block
      back into hash order. Plus the additional cost of the commit (above)
      
      | config | change |
      | --- | --- |
      | 4Mi entries / 8 commits | +6.0% (reproduced at +10.2%) |
      | 16Mi entries / 8 commits | +7.5% |
      | 4Mi entries / 32 commits | +7.8% |
      | 16Mi entries / 32 commits | +5.2% |
      | 16Mi entries / 128 commits | -9.5% |
      33a5d542
  5. 28 Aug, 2026 5 commits
    • Jiwon Choi's avatar
      Honor non-interactive mode in upgrade codemod prompts (#98030) · 920a7673
      Jiwon Choi authored
      ### Why?
      
      `@next/codemod upgrade --yes` accepts defaults for the upgrade command's
      prompts, but `next-request-geo-ip` asked its own deployment question
      inside `runTransform`. Because the non-interactive state was not
      forwarded, automated upgrades could stop at that nested prompt despite
      using `--yes`.
      
      ### How?
      
      Pass the resolved non-interactive state from `runUpgrade` into each
      transform. The geo/IP transform skips its deployment prompt in
      non-interactive mode while preserving the existing prompt for direct
      interactive runs.
      920a7673
    • Jiwon Choi's avatar
      Transform .mjs files with Next.js codemods (#98029) · 6fb98fae
      Jiwon Choi authored
      ### Why?
      
      The shared codemod runner only passed `tsx`, `ts`, `jsx`, and `js` files
      to jscodeshift. As a result, config transforms that recognize the
      supported `next.config.mjs` format never received those files, leaving
      migrations such as `experimental.turbo` to `turbopack` incomplete.
      
      ### How?
      
      Add `mjs` to the existing jscodeshift `--extensions` argument. Existing
      parser selection and Next.js config detection already support this
      format. Unsupported `next.config.cjs` files remain excluded.
      6fb98fae
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.11 · 0d4dc0c3
      next-js-bot[bot] authored
      0d4dc0c3
    • Marcos Hernanz's avatar
      Fix optimistic routing for encoded dynamic params (#97948) · a41e98e7
      Marcos Hernanz authored
      ## Summary
      
      Fixes #97842 by canonicalizing encoded pathname parts before using them
      as dynamic segment cache keys in optimistic route predictions. This
      keeps predicted route trees consistent with server Flight data and
      prevents query-only navigation from remounting pages when regular or
      catch-all params contain encoded characters.
      
      Add coverage that verifies bfcache IDs and form state are preserved for
      `@` in a regular dynamic param and for `@` plus `%2F` in a catch-all
      param.
      
      ## Verification
      
      - Existing encoded-slash route-cache E2E suite in Turbopack and webpack
      production modes
      - Existing optimistic-routing E2E suite in Turbopack and webpack
      production modes
      - `pnpm test-types`
      - `pnpm types`
      - `pnpm prettier-check`
      - `pnpm lint-ast-grep`
      - `pnpm lint-language`
      - Changed-file Prettier and ESLint checks via the pre-commit hook
      Co-authored-by: 's avatarvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
      a41e98e7
    • Marcos Hernanz's avatar
      Fix intercepted route params after Proxy rewrites (#97953) · 4d36801f
      Marcos Hernanz authored
      ## What?
      
      Preserve the final internal rewrite pathname in the RSC response when an
      earlier Proxy rewrite has already populated the rewritten-path header.
      
      This also adds an end-to-end regression assertion for a dynamic
      interception route behind a locale-injecting middleware rewrite.
      
      ## Why?
      
      The route resolver set the final marker-bearing pathname directly on the
      response, but router-server later reapplied the accumulated Proxy
      response headers. That restored the earlier markerless pathname. The
      client then parsed an intercepted dynamic param against that stale path
      and removed three real characters from the value.
      
      ## How?
      
      Mirror the final internal rewrite pathname into the accumulated
      response-header map. When router-server applies that map after route
      resolution, the last rewrite remains authoritative.
      
      Fixes #97939
      
      ## Tests
      
      - Production interception regression suite: 4/4 passed
      - Development interception regression suite: 4/4 passed
      - Related production rewrite/interception suites: 43/43 passed
      - Next package build, targeted ESLint, Prettier, and git diff checks
      passed
      4d36801f