1. 29 Oct, 2026 3 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.31 · 967c1520
      next-js-bot[bot] authored
      967c1520
    • Tobias Koppers's avatar
      perf(build): lazily require page-data helpers in build/utils (#100822) · a2536e65
      Tobias Koppers authored
      ### What?
      
      Defer the requires in `packages/next/src/build/utils.ts` that are only
      needed while collecting page data, so the main `next build` process no
      longer evaluates them at startup. The deferred modules are the edge
      sandbox, `load-components`, the incremental cache helper, app segment
      collection, the app/pages static-path builders and the HTTP agent setup.
      
      ### Why?
      
      `build/utils` is loaded eagerly by the main process, through
      `build/index` and through route discovery → `get-page-static-info`. Its
      top-level imports pulled in large dependency graphs, including
      `compiled/edge-runtime`, the incremental cache / response cache, the
      tracer and OpenTelemetry. Those are only used by `isPageStatic` and the
      component-loading helpers, which run in the build workers. The main
      process paid for evaluating them before `build()` started, then never
      used them.
      
      ### How?
      
      - Each of those dependencies is now `require`d at its call site, keeping
      the original call order. The types still come from `import type`.
      - The side-effect imports at the top of the file (`require-hook`,
      `node-polyfill-crypto`, `node-environment`) are untouched, so
      initialization order is the same in the main process and in workers.
      - After the change, the deferred modules are never loaded in the main
      process for the whole build. The work is removed, not moved inside
      `build()`.
      
      ### Measurements
      
      These are local measurements on one machine, alternating base and change
      runs. `bench/nested-deps-app-router-many-pages` has 1,000 pages and uses
      Turbopack. The metric is the time from profiler start to the first
      sample inside `build()`, taken from `next build
      --experimental-cpu-prof`.
      
      | Pair | Before | After |
      |---|---:|---:|
      | 1 | 244.7ms | 200.5ms |
      | 2 | 243.4ms | 184.4ms |
      | 3 | 255.6ms | 184.6ms |
      
      - **Mean:** 247.9 → 189.8ms (−23%).
      - **Total build time:** unchanged (~52–55s).
      - **`cli/next-build.js` require time:** median 251.8 → 207.3ms in a
      fresh process (30 interleaved samples each).
      - **Main-process modules, whole build of a small mixed app:**
        - Turbopack: 424 → 348 `next/dist` modules.
        - Webpack: 551 → 476 `next/dist` modules.
      
      ### Verification
      
      - **Smoke builds:** a small app with app router, edge, SSG, pages
      `getStaticProps`/`getStaticPaths` and middleware produces an identical
      route table before and after, with both Turbopack and webpack.
      - `pnpm test-start-turbo test/production/app-dir-edge-runtime-with-wasm
      test/production/conflicting-ssg-paths`
      - `pnpm test-start-webpack test/e2e/app-dir/app/standalone.test.ts
      test/production/build-output`
      - `packages/next/src/build/analysis/get-page-static-info.test.ts` unit
      tests
      - **Not run:** a webpack build of the 1,000-page benchmark. It fails
      during compilation with a native `std::bad_alloc` on the base commit as
      well, so it is unrelated to this change.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 60ff1dd9-ad2b-411e-8a67-e3842d2a1798 -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      a2536e65
    • Tobias Koppers's avatar
      perf(turbopack): canonicalize async loader availability (#100705) · ebcc2840
      Tobias Koppers authored
      ### What?
      
      Canonicalize async-loader availability before constructing loaders for
      dynamic `import()` and `next/dynamic`, so parents that make the same
      modules available share loader tasks instead of creating them once per
      page.
      
      Lazy-compilation proxies keep their activation paths stable; their
      actual targets still use canonicalization when their closures contain no
      further lazy proxies.
      
      ### Why?
      
      `AsyncLoaderModule` and `async_loader_chunk_item` are keyed by
      `AvailabilityInfo`. Both the available chunk groups and `entry_group`
      carry per-parent information. On v0 there are about 196K
      `async_loader_chunk_item` tasks for a few hundred targets.
      
      Intersecting availability with reachable groups alone isn't enough: a
      module shared with every page, such as `react/jsx-runtime`, keeps that
      intersection different per page.
      
      ### How?
      
      - **Precompute observed sets in `compute_chunk_group_info`.** Build a
      chunk-group graph from async, shared/shared-merged and collected
      references, then close over it per strongly connected component. For
      each async target, record the distinct chunk-group sets tested during
      chunking, their union, and whether it needs `entry_group`. Store this in
      a keyed cell on `ChunkGroupInfo`.
      - **Canonical availability.** From the union, remove each observed set
      that misses the parent availability. The result answers every observed
      intersection question like the original and depends only on those
      answers, not the parent. It can include groups not originally available;
      it is a representative, not a subset. Drop `entry_group` when it cannot
      be read.
      - **Filter inline at both call sites.**
      `AvailabilityInfo::canonicalize_for_async_loader` is used in
      `make_chunk_group` and next-api's `next/dynamic` loader construction. No
      filtering task per parent/target; equal resulting bitmaps share a cell.
      Unknown collected subgraphs conservatively keep the original
      availability.
      - **Lazy-compilation boundary.** `LazyCompilationProxyModule` implements
      the generic `ActivatableModule` marker. The pass stops at its async
      group and omits that group's narrowing entry, preserving the proxy
      loader's availability. Deferred references must start independent chunk
      groups, as documented by the marker.
      - Async ancestors reaching a proxy use the subset-safe intersection
      filter and keep `entry_group`, including for collecting modules that
      appear only on activation.
      - This prevents invented availability reaching an unknown target and
      keeps nested proxy stub paths stable when activation expands the graph.
      - Actual targets with proxy-free closures still canonicalize. Ancestors
      containing more lazy proxies may remain per-parent; this does not
      promise full deduplication in lazy mode.
      - **Distinct manifest names.** Base `ManifestAsyncModule::content_ident`
      on the manifest module's own ident, not the inner module's ident. Empty
      availability no longer makes the manifest and inner module collide; the
      lazy activation key remains part of the path.
      - **Cached chunk-group identity hashes.**
      `ChunkGroupInfo::chunk_group_ident_hashes` renders and hashes each
      chunk-group identity once per graph. `AvailableChunkGroups::hash` then
      reads that one cell, sorts its members' identity hashes and combines
      them, instead of rendering every member identity in every availability
      hash.
      
      The second commit fixes two reproducible lazy-import regressions exposed
      by the initial canonicalization: duplicate output paths and activation
      404s. They were not flakes.
      
      The third commit addresses the vercel-site cold-build CPU regression
      found in benchmarks: canonical availability sets were larger, and
      `AvailableChunkGroups::hash` repeated identity rendering for every
      member. Output names intentionally change because the set hash now
      combines per-identity hashes.
      
      ### Measurement
      
      Measured before rebasing onto canary's `Bitset` migration (#100643,
      #100630); not re-measured since.
      
      Production build of a generated app: N client pages, each using
      `next/dynamic` on the same five targets with private dependencies; JSX
      targets additionally share `react/jsx-runtime` with every page. Lazy
      compilation is off.
      
      | Variant | N | `async_loader_chunk_item` tasks |
      `AsyncLoaderModule::new` tasks | Total tasks |
      |---|---|---|---|---|
      | plain | 10 | 100 → 10 | 150 → 15 | 115,052 → 112,153 |
      | plain | 100 | 1,000 → 10 | 1,500 → 15 | 237,992 → 206,203 |
      | JSX | 10 | 100 → 10 | 150 → 15 | 115,131 → 112,257 |
      | JSX | 100 | 1,000 → 10 | 1,500 → 15 | 238,071 → 206,307 |
      
      `compute chunk group info` CPU: 2.81 → 3.64 ms at N=100, including 0.75
      ms for the new pass. After the lazy fix, quick N=100 runs of both
      variants still produce 10 loader tasks and 15 loader-module tasks.
      
      **No established build-wall-time gain:** the small synthetic app's
      timings overlap. Not measured on v0.
      
      After the third commit, on the JSX app at N=100, availability-hash task
      executions stay at 5, the new graph task runs once, and
      `AssetIdent::to_string` calls fall from 13,014 to 11,247 in both runs.
      One trace per arm reduces total `AvailableChunkGroups::hash` span CPU
      from 3.10 ms to 1.72 ms, including the first identity-hash computation.
      Real-app benchmarks have not been rerun after this commit.
      
      ### Verification
      
      - Unit coverage: disjoint and shared targets; nested async/shared/merged
      references and cycles; isolated/traced references; collect/emit and
      entry-group decisions; keyed-cell invalidation; exhaustive canonical and
      subset-filter properties.
      - Activation regression test compares inactive/active graphs by
      chunk-group keys, checks stable subset availability and retained
      `entry_group` above a proxy, unchanged proxy availability, and
      canonicalization of activated and unrelated targets.
      - New `collect/async` execution fixture.
      - Lazy dev suites: `lazy-dynamic-imports` (19/19),
      `lazy-dynamic-chunk-list-collision` (1/1), and collision again with
      cache components and cached navigations (1/1).
      - Focused Turbopack dev and production suites:
      `layout-segment-chunk-sharing`, `app-dir/dynamic`,
      `app-dir/dynamic-import`, `404-page-router`, `next-dynamic`,
      `pages-app-next-dynamic-preload`.
      - All 458 Rust snapshot/execution tests pass. Initial optimization
      renamed 45 outputs with identical mapped contents; the lazy fix
      introduces no additional snapshot changes. The identity-hash commit
      renames 15 more outputs; a mechanical check maps all 15 and finds
      identical contents apart from the changed names.
      - Core/ecmascript units: 813 passed, 2 skipped. Workspace fmt, check,
      clippy and docs pass with warnings denied. After the identity-hash
      change, lazy imports (19/19), lazy collision (1/1), and
      `app-dir/dynamic` production (12/12) pass with a rebuilt native binary.
      
      ### Out of scope
      
      - Lowering entry groups into chunking edges or narrowing them to
      subsets.
      - Canonicalizing proxy loaders themselves or resolving their manifests
      by activation key on the server.
      
      <!-- NEXT_JS_LLM_PR -->
      
      <!-- fleet 4f67c6f7-bbe2-454b-9a17-822a60ef8f7e -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      ebcc2840
  2. 28 Oct, 2026 19 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.30 · 7fd2d0a6
      next-js-bot[bot] authored
      7fd2d0a6
    • Andrew Clark's avatar
      Add criteria for Vercel Agent code review (#100846) · 08442e3a
      Andrew Clark authored
      Adds the criteria Vercel Agent will use to review Next.js team PRs, and
      to decide whether to approve them or escalate to an area owner.
      
      Automated approvals will only run for members of the Vercel GitHub org
      who are also on an allowlist of core Next.js contributors.
      
      REVIEW.md is the main entry point for the agent. (A suggestion to the
      human reviewing this review procedure: imagine you're an agent and open
      that file.) It describes the protocol, then routes the agent to the
      appropriate tools and documents needed to conduct its review.
      
      I asked an agent to analyze the codebase and split it into areas with
      different owners. Each area can have its own review criteria. The
      initial set of areas and owners is just a starting point. Please submit
      changes, I know some of them will be wrong! The area-specific review
      criteria are also mostly empty.
      
      I seeded the agent with a starting set of "core" criteria. These are
      also not set in stone. I collected them from our existing skills and my
      own institutional knowledge of our team's practices. Please submit
      changes if you disagree with any, or want to propose more.
      
      **It's expected that the initial version of the review procedure will
      need significant tuning.** I ran some lightweight evals on historical
      PRs to check its effectiveness. We will continue to do this on a regular
      basis. The goal is for 90%+ of code reviews to result in the correct
      signal.
      
      **A human is still required for merge.** We are going from 2 humans in
      the loop to 1. Not 0. The quality of a PR is ultimately the
      responsibility of its merger and author.
      
      Be extra rigorous and vigilant as we iterate on this new review
      procedure.
      
      Refer to REVIEW.md for full details.
      
      ---------
      Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
      08442e3a
    • Andrew Clark's avatar
      Add experimental.hydrationChangeEvent flag (#99610) · 379f32c0
      Andrew Clark authored
      Adds an experimental config flag, `experimental.hydrationChangeEvent`,
      that opts the `app` directory into React's experimental release channel
      (`react@experimental`) — the same channel already selected by `taint`,
      `transitionIndicator`, `gestureTransition`, and `blockingSSR`.
      
      The experimental React build ships React's internal
      `enableHydrationChangeEvent` feature flag, which isn't in React's canary
      channel yet. This flag lets teams try it ahead of that. It has no effect
      of its own beyond selecting the experimental React build.
      
      The flag is wired through `needsExperimentalReact` on the Next.js side
      and the matching `use_react_experimental` switch in Turbopack, so both
      bundlers pick the experimental build.
      
      <!-- NEXT_JS_LLM -->
      379f32c0
    • Benjamin Woodruff ‮'s avatar
      Turbopack: Move reference to bincode's virtue dependency into a vercel-labs… · 4bfbf238
      Benjamin Woodruff authored
      Turbopack: Move reference to bincode's virtue dependency into a vercel-labs owned fork repository (#100847)
      
      This is a perma-fork now that it appears there's zero chance upstream
      will come back. Let's move it out of a personally-owned repo (not a
      security issue, because the commit hash was pinned by the lockfile).
      4bfbf238
    • Aurora Scharff's avatar
      Ignore expected upgrade nudges in Agent Feedback (#100840) · eda07a70
      Aurora Scharff authored
      ### What?
      
      - Exclude intentional one-time `SecurityFatalError` and
      `UpgradeNudgeError` upgrade stops from the private Agent Feedback
      reporting protocol.
      - Keep retries that remain blocked, or documented remediation that
      fails, eligible as unexpected behavior.
      - Add an Agent Feedback eval with one genuine documentation mismatch and
      one expected upgrade stop. It requires the documentation report and
      rejects any report for the expected stop.
      - Add focused coverage for the internal protocol loader.
      
      ### Why?
      
      The Next.js upgrade gate intentionally stops a successful command once,
      explains that an upgrade is recommended, and allows the next run to
      continue. Agents were treating that expected stop as a Next.js error and
      filing duplicate feedback. The private reporting protocol should
      distinguish the expected gate from an actual failure of the retry or
      remediation path.
      
      This does not change the public generated `AGENTS.md` instructions.
      
      ### Verification
      
      | Check | Result |
      | --- | --- |
      | Agent Feedback CLI and protocol tests | 25 passed |
      | Eval fixture/config validation | Passed |
      | Prettier | Passed |
      | Agent eval model run | Attempted twice with the rebuilt local package;
      both shared AI Gateway requests failed before model execution |
      eda07a70
    • Tobias Koppers's avatar
      bench: fix nested-deps-app-router-many-pages build harness (#100820) · f922205f
      Tobias Koppers authored
      ### What?
      
      Fixes the `bench/nested-deps-app-router-many-pages` harness so `node
      bench.mjs build` builds and reports this app, and the build logs no
      config warnings.
      
      ### Why?
      
      - The build step ran `next build ./bench/nested-deps-app-router`, a
      different bench app, but read `.next/trace` from this app's directory.
      The reported build duration didn't come from this app, and the run
      failed when the other app's components weren't generated.
      - `.next` was removed relative to the current working directory instead
      of this app's directory. Running the script from anywhere else skipped
      the cleanup.
      - `next.config.js` set `eslint.ignoreDuringBuilds`, which Next.js 16
      rejects with the warning `Unrecognized key(s) in object: 'eslint'`.
      - The scripts set `NEXT_PRIVATE_LOCAL_WEBPACK=1`. That variable only
      makes Next.js resolve a project-local `webpack` package; it doesn't
      select webpack. Builds already use Turbopack by default, so the scripts
      looked like they benchmarked webpack when they didn't.
      
      ### How?
      
      - The build step now targets this app, and both `.next` cleanups resolve
      against the app directory, so the build and the trace it reads come from
      the same place.
      - Removed the unsupported `eslint` config. The `--cpu-prof` workaround
      stays.
      - Dropped the env var so every script uses the default bundler
      (Turbopack). This matches `bench-warm-build.mjs`, which already
      benchmarks Turbopack. `cross-env` is no longer used, so it's removed
      from the package and the lockfile.
      
      The sibling `bench/nested-deps` and `bench/nested-deps-app-router` apps
      have the same stale env var, and the latter also has the `eslint` key.
      They're left for a separate change.
      
      ### Verification
      
      - After `pnpm prepare-bench`, `node bench.mjs build` ran all three test
      cases. Each was a Turbopack build of this app's 3002 pages, the duration
      was read from the app's own `.next/trace`, and no config warnings were
      logged.
      - Before the change, the same command built
      `bench/nested-deps-app-router` and logged the `eslint` warning.
      - Not run: the dev/HMR and CPU-profiling modes.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet fade2a6c-31b0-41a3-bc95-33dd0ae47b2a -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      f922205f
    • Aurora Scharff's avatar
      Add model metadata to Agent Feedback (#100806) · d4cd1ab1
      Aurora Scharff authored
      ## Summary
      
      Agent Feedback currently records the coding harness but not the model
      that produced a report. In a recent sample, 61 of 108 reports named only
      a harness such as Claude Code, opencode, or Codex. That prevents us from
      comparing production friction with eval results by model, harness
      version, or reasoning effort.
      
      This updates the Agent Feedback protocol to schema version 6 and asks
      reporting agents to include structured:
      
      - harness version
      - model identifier
      - reasoning effort
      
      Agents use `unknown` when their environment does not expose a value
      instead of inferring it. Existing schema v4 and v5 report links remain
      valid.
      
      ## Companion changes
      
      - https://github.com/vercel-labs/next-maintainer-agent/pull/635 accepts
      and stores v6 metadata while retaining v4 and v5 compatibility. This is
      merged.
      - https://github.com/vercel/front/pull/94097 updates the nextjs.org
      review UI to parse v6 reports and show the harness, harness version,
      model, and reasoning effort under **Attached to this report**.
      
      The receiver must support v6 before this protocol change lands. The
      Front change makes the added metadata visible during report review but
      does not block receipt of v6 reports.
      
      ## Verification
      
      - `pnpm exec jest --runInBand --runTestsByPath
      packages/next/src/cli/internal/agent-feedback-instructions.test.ts`
      - `pnpm --filter=next build`
      
      <!-- NEXT_JS_LLM -->
      d4cd1ab1
    • Niklas Mischkulnig's avatar
      Fix `export const foo = function bar(){}` in server reference transform (#100830) · d9874838
      Niklas Mischkulnig authored
      It was doing something like this:
      ```js
      "use server";
      export const foo = async function bar() {
          return 'exported named function expression';
      };
      ensureServerEntryExports([
          bar, // should be foo!
      ]);
      registerServerReference(bar, "003c8ed39a99caf636869d076cc7cae786a4053164", null); // shoudl be foo!
      ```
      
      leading to
      ```
      ⨯ ReferenceError: quux is not defined
          at module evaluation (test/development/app-dir/source-mapping/app/actions1.ts:15:35)
          at module evaluation (test/development/app-dir/source-mapping/app/page.tsx:2:1)
        13 | }
        14 |
      > 15 | export const qux = async function quux() {
           |                                   ^
        16 |   return 'exported named function expression'
        17 | }
        18 | {
        page: '/'
      }
      ```
      d9874838
    • Niklas Mischkulnig's avatar
      Use fast-jwt instead of jsonwebtoken (#100818) · f111dc7f
      Niklas Mischkulnig authored
      `jsonwebtoken` still uses `SlowBuffer` and is thus incompatible with
      Node.js 26 (`SlowBuffer` was removed):
      https://github.com/auth0/node-jsonwebtoken/issues/992
      
      Use https://npmx.dev/package/fast-jwt instead of
      https://npmx.dev/package/jsonwebtoken.
      
      https://npmx.dev/package/jose is ~~way bigger~~ only has async APIs
      f111dc7f
    • Tobias Koppers's avatar
      turbo-persistence: use partition_point for batch lookup bounds (#100821) · 4e03bf93
      Tobias Koppers authored
      Follow-up to #100620, addressing [this review
      comment](https://github.com/vercel/next.js/pull/100620#discussion_r4399047345).
      
      ### What?
      
      `MetaFile::batch_lookup_entry` now finds the cells inside an SST file's
      hash range with `partition_point` instead of `binary_search_by`.
      
      ### Why?
      
      The old code used `binary_search_by` with a comparator that never
      returns `Equal` (`.then(Ordering::Greater)` / `.then(Ordering::Less)`)
      and then took the insertion point with `.err().unwrap()`.
      `partition_point` states the bounds directly and is easier to read.
      
      ### How?
      
      - Start: `cells.partition_point(|&(hash, _)| hash < range.min_hash)`,
      the first cell with `hash >= min_hash`.
      - End: `cells.partition_point(|&(hash, _)| hash <= range.max_hash)`, the
      first cell with `hash > max_hash`.
      
      Both return the same indices as before for every input, including
      duplicate hashes, empty slices, and bounds at `0` or `u64::MAX`. The now
      unused `Ordering` import is removed. There is no behavior change.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 2e9e7c99-0cc2-4e7b-9e62-627c0627638b -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      4e03bf93
    • Tobias Koppers's avatar
      ci: don't run non-adapter + cache components deploy tests in PRs (#100824) · ced39776
      Tobias Koppers authored
      ### What?
      
      Drop the non-adapter builder + cache components combination from the
      "Test new and changed tests when deployed" PR matrix. The matrix had 20
      entries (group × builder × cache components); it now has 15:
      
      - adapter, cache components off
      - adapter, cache components on
      - non-adapter, cache components off
      
      ### Why?
      
      #100591 added the full builder × cache-components product. The release
      deploy tests never run cache components with the non-adapter Turbopack
      builder, so PR CI was testing a combination that release testing doesn't
      cover.
      
      ### How?
      
      The job gets a matrix `exclude` entry with a comment explaining why. The
      remaining 15 entries keep their names, `stepName`s, env and commands, so
      their report history continues. Nothing else in the workflow changes.
      
      Verified by parsing the workflow and expanding the matrix with GitHub's
      exclude rules. Every remaining rendered script was run with `node`
      stubbed, and each one matches canary's env and command. The `exclude`
      entry is the only difference from canary.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 115592cd-38e9-4ec3-904b-f1c778e1e1d9 -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      ced39776
    • Tobias Koppers's avatar
      Enforce strict rustdoc (incl. private items) across the Rust workspace (#100768) · 4084a0f4
      Tobias Koppers authored
      ### What?
      
      Makes rustdoc warnings fail CI for the whole Rust workspace, including
      private items, and fixes every existing warning so the new check starts
      green.
      
      - New `scripts/check-rustdoc.sh` runs `RUSTDOCFLAGS="-D warnings" cargo
      doc --workspace --no-deps --document-private-items`.
      - The existing `rustdoc check` job in `build_and_test.yml` now runs that
      script before `scripts/deploy-turbopack-docs.sh`. The public `next-*`
      docs build is unchanged.
      - Fixes the warnings across the workspace's Rust crates (turbo-tasks,
      turbo-tasks-backend, turbo-persistence, turbopack-*, next-core,
      next-api, next-napi-bindings, …).
      
      ### Why?
      
      The existing `rustdoc check` job only documented the public items of
      five `next-*` crates and didn't treat warnings as errors. Broken
      intra-doc links and other rustdoc warnings went unnoticed everywhere
      else. Running strict private-items docs over the whole workspace found
      about 60 of them.
      
      ### How?
      
      The Rust source changes are doc comments only. The only other doc edit
      is one link target in `singleton_pattern.md`. Nothing is silenced with
      `#[allow]`, and no imports or visibility changes were added for docs.
      Types of fix:
      
      - **Unresolved links**: point to the correct full path
      (`turbo_tasks::…`, `crate::…`, `Self::…`). Some links named renamed or
      moved items, for example `Effect::apply` → `CapturedEffect::apply` and
      `dec_in_flight` → `decrement_in_flight`. Those now point to the current
      item.
      - **Links to items rustdoc can't link to**: plain code text. These are
      test-only or feature-gated items, `doc(hidden)` items, private items in
      another crate, and a private trait rustdoc doesn't resolve.
      - **Ambiguous `crate::value`** (module and macro): `macro@crate::value`.
      - **Bare URLs**: wrapped in `<…>`.
      - **Unclosed HTML tags** from generics such as `Option<T>`: put in
      backticks.
      - **Redundant explicit link targets**: removed.
      
      The check runs with the workspace's default features on the CI target.
      It doesn't cover every feature or platform combination.
      
      ### Verification
      
      - `./scripts/check-rustdoc.sh && ./scripts/deploy-turbopack-docs.sh`
      (the exact CI step) passes locally.
      - `RUSTDOCFLAGS='-D warnings' cargo doc --workspace --no-deps` (public
      items) passes.
      - Negative check: a temporary broken intra-doc link made
      `scripts/check-rustdoc.sh` exit non-zero.
      - `cargo fmt --all --check` is clean.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 4bbc2447-5ae3-4b88-9649-a6b5ff30491e -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
      4084a0f4
    • Jiwon Choi's avatar
      Drain the maintainer auto-close queue in one run (#100733) · 05d13d45
      Jiwon Choi authored
      > [!TIP]
      > Best reviewed by hide whitespace:
      [files?w=1](https://github.com/vercel/next.js/pull/100733/files?w=1).
      
      Previously, were checking to close issue 1 per hour. Now that check
      closes all availables at once. Currently maxed to 5 from agent side.
      05d13d45
    • next-js-bot[bot]'s avatar
      Update font data (#100813) · 68406a4c
      next-js-bot[bot] authored
      This auto-generated PR updates font data with latest available
      Co-authored-by: 's avatarnext-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
      68406a4c
    • Niklas Mischkulnig's avatar
      test: fix native addon compilation on Node.js 26 (#100819) · 8200d896
      Niklas Mischkulnig authored
      These failed to compiled on Nodejs 26
      ```
      .../node_modules/native-addon install: ../addon.cc:8:35: error: 'class v8::Context' has no member named 'GetIsolate'
      .../node_modules/native-addon install:     8 |   v8::Isolate* isolate = context->GetIsolate();
      .../node_modules/native-addon install:       |                                   ^~~~~~~~~~
      .../node_modules/native-addon install: make: *** [native_addon.target.mk:108: Release/obj.target/native_addon/addon.o] Error 1
      .../node_modules/native-addon install: make: Leaving directory '/vercel/path0/node_modules/.pnpm/native-addon@file+native-addon/node_modules/native-addon/build'
      .../node_modules/native-addon install: gyp ERR! build error
      .../node_modules/native-addon install: gyp ERR! stack Error: `make` failed with exit code: 2
      .../node_modules/native-addon install: gyp ERR! stack at ChildProcess.<anonymous> (/vercel/path0/.vercel/cache/corepack/home/v1/pnpm/12.9.1/dist/node_modules/node-gyp/lib/build.js:219:23)
      .../node_modules/native-addon install: gyp ERR! System Linux 6.18.49
      .../node_modules/native-addon install: gyp ERR! command "/node26/bin/node" "/vercel/path0/.vercel/cache/corepack/home/v1/pnpm/12.9.1/dist/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
      ```
      8200d896
    • Tobias Koppers's avatar
      Turbopack: wait for trace file changes after format errors (#99847) · 9da349b7
      Tobias Koppers authored
      ### What?
      
      `turbo-trace-server` no longer re-reads a trace file every 500 ms after
      it was rejected with a format error. It prints the error once, prints
      `Waiting for the trace file to change...`, and reads the file again only
      once it changes (different size, modification or creation time, or on
      unix a different file at the path) or is removed.
      
      ### Why?
      
      `TraceReader::try_read` returned `true` after printing `Trace file
      error: ...`, so `TraceReader::run` slept 500 ms and read the whole file
      again, forever. With the `TRACEv1` header check (#99781), every old
      `TRACEv0` trace hit this: the server printed the same error twice a
      second (10 times in 5 s locally). Corrupt trace data behaved the same
      way.
      
      ### How?
      
      - Both format-error paths (format detection, and decoding with
      `format.read`) take a metadata snapshot of the open file and poll the
      path's metadata once per second until it differs. Only metadata is
      compared, so a rewrite that keeps size and timestamps the same (and on
      unix the same file) isn't noticed.
      - Valid traces, live tailing, I/O errors and `STOP_AT` behave as before.
      
      ### Verification
      
      - New unit test: a `TRACEv0` file and a corrupt `TRACEv1` file are not
      read again for 2.5 s, and replacing them with a valid trace loads it. It
      failed before this change.
      - New unit test for change detection: size change, same-size rewrite,
      replacement by another file, and removal.
      - Manual, release `turbo-trace-server`:
        - `TRACEv0` file for 5 s: error printed once (before: 10 times).
      - Corrupt `TRACEv1` file for 3 s: error printed once (before: 6 times).
      - Replacing a rejected `TRACEv0` file with a real `TRACEv1` trace while
      the server runs loads all 39,490 spans without a restart.
      - Only run locally on Linux; Windows and macOS are covered by CI.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 4a52842b-f1a2-43cb-9779-3655caada6a0 -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      9da349b7
    • Luke Sandberg's avatar
      turbo-persistence: parallelize large batch_get reads (#100620) · a72565ab
      Luke Sandberg authored
      ### What?
      
      Parallelize large `TurboPersistence::batch_get` calls in
      `turbo-persistence`.
      
      - Batches with **more than 2048 keys** (`PARALLEL_BATCH_GET_THRESHOLD`)
      are split into chunks and run on the database's existing
      `ParallelScheduler`. Smaller batches run serially, one chunk per shard.
      - `split_into_batch_chunks` aims for **4 chunks per task the scheduler
      can run at the same time** (like `turbo_tasks::util::good_chunk_size`).
      Every chunk stays inside _one shard_ of the family's current shard
      index, so small shards produce smaller chunks.
      - New `ParallelScheduler` methods:
      - `parallelism()`: the number of tasks the scheduler can run at once.
      The turbo-tasks scheduler returns
      `turbo_tasks::parallel::available_parallelism()`, `SerialScheduler`
      returns 1.
      - `try_parallel_for_each_task_mut`: runs exactly one task per (already
      chunked) item.
      - Less memory traffic in `batch_get`:
        - The sort is over compact `(u64 hash, u32 index)` cells.
      - Values are materialized as soon as an SST lookup finds them and
      written directly into the output `Vec`. There is no final loop to
      re-order the results.
      - Parallel chunks write disjoint indices concurrently through a small
      `ConcurrentSlice`.
      - Each chunk tracks the keys already found in newer SST files with a
      `turbo_bitset::Bitset` backed by a `SmallVec`, plus a counter. The
      bitset is preallocated for the chunk's positions (`Bitset::with_len`)
      and its `SmallVec` stores up to 256 positions inline, so typical chunks
      don't heap-allocate and larger chunks allocate their known size once.
        - `MetaFile::batch_lookup_entry` was adapted to match.
      - `batch_get` now requires `K: QueryKey + Sync`. All existing callers
      already satisfy it.
      
      ### Why?
      
      Warm builds restore task data with a few very large batches: up to about
      68K keys, ~24–27 calls over 2048 keys per build. Those reads are
      expensive serially.
      
      ### Results
      
      Warm-build benchmark from #100570
      (`bench/nested-deps-app-router-many-pages`, `bench-warm-build.mjs
      --files=1000`) on a 32 vCPU Linux VM with release native builds.
      
      The first version of this PR (fixed 256-key chunks), interleaved on the
      same machine against canary and against itself with parallelism forced
      off (benchmark-only env override). 12 iterations with 3 warm-up, i.e. 9
      timed builds per run:
      
      | warm compile, median | canary | this PR, serial | this PR, 2048 |
      |---|---|---|---|
      | pass A | 7.70 s | 7.70 s | **6.80 s** |
      | pass B | 8.20 s | 8.20 s | **7.20 s** |
      
      - That is about **0.9–1.0 s (~12%)** faster compile with 1,000 changed
      files. Earlier rounds on other machines point the same way (0.6–1.3 s).
      - The serial restructuring on its own is neutral, so the gain comes from
      parallelism.
      
      Switching from fixed 256-key chunks to parallelism-based chunk counts
      (and to `turbo_bitset::Bitset`), 3 interleaved passes with 6 timed
      builds each, on one machine:
      
      | warm compile / wall, median | 256-key chunks | parallelism-based |
      |---|---|---|
      | pass 1 | 7.10 / 13.32 s | 7.75 / 13.89 s |
      | pass 2 | 6.85 / 12.57 s | 6.65 / 11.96 s |
      | pass 3 | 7.25 / 13.15 s | 6.85 / 12.87 s |
      
      No consistent difference in warm builds. In a micro benchmark (Rayon, 32
      threads, two passes) 4K-key batches get ~21–38% faster, 16K-key batches
      are about the same, and 64K-key batches are mixed (up to ~10–16% slower
      in some cases).
      
      Per-call profile of a `--files=1000` warm build (~148K `batch_get`
      calls, ~1.84M keys):
      - calls with more than 2048 keys carry ~36% of the keys;
      - their summed elapsed time drops from **1.9–2.4 s** (serial) to
      **0.21–0.25 s** (parallel);
      - calls with 128 keys or fewer are 99.96% of all calls and are not
      affected by this change.
      
      Much smaller thresholds were also tried but there was no benefit.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 2e9e7c99-0cc2-4e7b-9e62-627c0627638b -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      a72565ab
    • Niklas Mischkulnig's avatar
      Turbopack: ignore fully dynamic alternatives when tracing file paths (#100651) · 34bfd9bb
      Niklas Mischkulnig authored
      ## Summary
      
      With Turbopack, a file read whose path is _either_ an unknown value _or_
      a known file traced the **entire project** into `.nft.json`, including
      `public/`. It also printed "Dynamic filesystem access causes tracing of
      the whole project". Two examples:
      
      - `readFileSync(options.path ?? path.join(process.cwd(),
      'manifest.json'))`
      - a default parameter `p = path.join(process.cwd(), 'manifest.json')`
      that is then read
      
      The default-parameter form regressed in 16.4: #97867 models default
      params as "caller's argument or the default". The `??` form behaved like
      this before.
      
      A bare unknown path (`readFileSync(p)`) is already skipped when
      `ignore_dynamic_requests` is on, as it is for Next.js server and client
      code. The mixed case slipped through because `has_constant_parts()` is
      true as soon as _any_ alternative is constant. The unbounded alternative
      then resolved to every file in the project.
      
      ### Approach
      
      A new `Pattern::filter_non_dynamic()` in `turbopack-core` keeps only the
      top-level alternatives that have constant parts. When dynamic requests
      are ignored, the file-tracing handlers trace that filtered pattern. The
      handlers are: fs reads, `fs.readdir`, `path.join`, `path.resolve`,
      `child_process.spawn` (its file reference) and `child_process.fork`. As
      a result:
      
      - the known file is traced, and the unknown alternative is ignored, just
      as a bare unknown path is;
      - fully dynamic patterns behave as before: a "very dynamic" lint, then
      skip;
      - partially bounded paths such as `path.join(process.cwd(), name)` still
      trace the project and still warn;
      - module requests (`require`, `import()`, `new URL`, workers), externals
      tracing, standalone nft (`ignore_dynamic_requests` off) and webpack are
      unchanged.
      
      ### Behavior change
      
      A path that only exists in the dropped dynamic alternative is no longer
      traced. It now ends up exactly where a bare `readFileSync(foo)` already
      does. The only thing it got from the old behavior was a whole-project
      trace, which was a failure in its own right, not a working fallback. For
      the same reason the whole-project warning goes away for these cases.
      
      `child_process.fork(x ?? './worker.js')` creates a module reference, so
      in that case this also narrows what gets bundled to `./worker.js`.
      
      ### Tests
      
      - `Pattern::filter_non_dynamic` has unit tests.
      - `test/production/standalone-mode/tracing-static-files` covers the
      `??`, default-parameter and bare-dynamic forms by reading the page's
      `.nft.json`:
        - **Turbopack:** the known data files are traced.
      - **Both bundlers:** the unreferenced `data/unrelated.txt` and
      `next.config.js` aren't traced.
      
        Without the fix, Turbopack lists the whole project.
      - The same suite has an external package (`serverExternalPackages`) with
      the same patterns, covering the externals tracing context where
      `ignore_dynamic_requests` is off. There, the dynamic alternatives are
      kept and traced from the reading module's directory, but they don't
      escape into the project. Project-root files referenced via
      `process.cwd()` from external packages aren't traced; that predates this
      PR and is asserted as current behavior.
      
      ## Verification
      
      - Manual check: in an app whose instrumentation hook reads a manifest
      through a default parameter, the trace went from the whole project (260
      MB from a large `public/` asset) to just the manifest and the generated
      chunks.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet ad3254c1-cab0-4e7e-89a5-84a673c8e16a -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      34bfd9bb
    • Joseph's avatar
      docs: scope whole-route dynamic rendering claim for cookies to the previous model (#100811) · caa60a93
      Joseph authored
      ## Summary
      
      The production checklist and the `cookies` API reference said
      request-time APIs opt the entire route into dynamic rendering, which
      contradicts the Cache Components caching guide (reading `cookies()`
      inside `<Suspense>` streams only that subtree). Both pages now lead with
      the Cache Components behavior and scope the whole-route claim to
      "Without Cache Components".
      
      - `production-checklist.mdx`: rewrite the Request-time APIs bullet to
      point at Suspense and the caching guide; remove the outdated "Partial
      Prerendering (experimental)" Good to know.
      - `cookies.mdx`: split the whole-route sentence into a "Without Cache
      Components" bullet and note that only the Suspense subtree streams with
      Cache Components.
      
      <!-- NEXT_JS_LLM -->
      caa60a93
  3. 27 Oct, 2026 18 commits
    • Joseph's avatar
      docs: note Suspense requirement for connection() with Cache Components (#100810) · 7356b0bc
      Joseph authored
      ## Summary
      
      The `connection()` API reference did not say that, with Cache
      Components, the calling component needs a `<Suspense>` boundary above
      it. The caching guide and the `blocking-prerender-dynamic` error page
      both require one, and the `io()` and `navigation()` references show it.
      
      Adds a Good to know bullet: the boundary can be direct or an ancestor
      such as `loading.js`, the nearest fallback is prerendered into the
      static shell, and without a boundary navigations block instead of being
      instant.
      
      ## Verification
      
      - Checked link targets: `loading`, glossary `#static-shell`,
      `/docs/messages/blocking-prerender-dynamic`
      
      <!-- NEXT_JS_LLM -->
      7356b0bc
    • Aurora Scharff's avatar
      Add a CLI for reviewing agent feedback (#100739) · c41d1beb
      Aurora Scharff authored
      ## Why
      
      Agent Feedback reports are created inside coding environments that often
      cannot launch a local browser. The previous instructions made the final
      handoff depend on the agent finding and invoking host-specific browser
      tooling. In headless, sandboxed, or remote sessions, that step could
      fail even when the anonymized report itself was valid, leaving the
      maintainer without a usable review link.
      
      This happened in practice when an agent could not share its feedback and
      had to be told to run a browser command manually. Browser control should
      not be part of the Agent Feedback reporting contract.
      
      ## What changed
      
      - add the hidden `next internal agent-feedback [report]` command as the
      supported handoff for an encoded v5 Agent Feedback report
      - keep the command internal because it is protocol machinery, not a
      public semver-covered CLI surface
      - accept the report as a positional argument or through stdin, validate
      the complete v5 schema, and always print the review URL before
      attempting to open the default browser
      - preserve the printed URL when browser launching is unavailable or
      fails
      - bound stdin to 16 KiB and a five-second read deadline using Node's
      async iterator and `AbortController`
      - support `--dry-run` for validation and URL generation without opening
      a browser
      - update the Agent Feedback protocol and evals to use the internal CLI
      instead of host-specific browser commands
      
      This keeps the report anonymized and makes CLI output—not browser
      availability—the reliable source of truth for the maintainer handoff.
      
      ## Verification
      
      - `pnpm jest --runInBand
      packages/next/src/cli/internal/agent-feedback.test.ts
      packages/next/src/cli/internal/agent-feedback-instructions.test.ts` (23
      tests)
      - `pnpm prettier --check packages/next/src/agent-feedback/protocol.md
      packages/next/src/bin/next.ts
      packages/next/src/cli/internal/agent-feedback.ts
      packages/next/src/cli/internal/agent-feedback.test.ts`
      - `pnpm eslint packages/next/src/bin/next.ts
      packages/next/src/cli/internal/agent-feedback.ts
      packages/next/src/cli/internal/agent-feedback.test.ts`
      - `pnpm --filter=next types`
      - `pnpm --filter=next build`
      - built CLI smoke test: `node packages/next/dist/bin/next internal
      agent-feedback --help`
      
      ### Agent Feedback evals
      
      Variant: `agent-feedback`; model: `claude-opus-4-8`; one run per eval.
      
      | Eval | Coverage | Last completed model run | Exact-head rerun
      (`77e626ee5c9`) |
      | --- | --- | --- | --- |
      | `agent-056-agent-feedback-routine-debugging` | Routine debugging does
      not open a feedback review | 1/1 passed (192.6s) | Gateway fetch failed
      before model execution (retried once) |
      | `agent-057-agent-feedback-anonymization` | The report remains
      anonymized and uses `next internal agent-feedback` | 1/1 passed (389.9s)
      | Gateway fetch failed before model execution |
      | `agent-058-agent-feedback-distinct-issues` | Distinct issues produce
      separate reports and internal CLI invocations | 1/1 passed (330.8s) |
      Gateway fetch failed before model execution |
      
      The exact-head reruns produced no model output or classifier result; all
      three failed in the shared AI gateway after 180–195 seconds. Fixture
      generation remains up to date, and deterministic CLI tests/builds pass
      on the exact head.
      
      <!-- NEXT_JS_LLM -->
      c41d1beb
    • Joseph's avatar
      docs: forward allow-listed headers and catch fetch errors in BFF proxy example (#100808) · 4bf9d910
      Joseph authored
      ## Summary
      
      The "Proxying to a backend" example in the Backend for Frontend guide
      built the upstream request with `new Request(proxyURL, request)`, which
      forwards every incoming header, including `Cookie` and `Authorization`,
      to the external backend. The example now forwards an allow-list
      (`accept`, `content-type`), and the intro says why.
      
      It also returned `fetch()` without `await` inside `try`, so a rejected
      fetch skipped the `catch` and the 500 fallback never ran. It now uses
      `return await fetch(proxyRequest)`.
      
      - docs: forward allow-listed headers and catch fetch errors in BFF proxy
      example
      
      <!-- NEXT_JS_LLM -->
      4bf9d910
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.29 · 8f7dd001
      next-js-bot[bot] authored
      8f7dd001
    • Tobias Koppers's avatar
      turbo-bitset: make block storage pluggable (#100779) · 4bb4e8f1
      Tobias Koppers authored
      ### What?
      
      `turbo_bitset::Bitset` can now use different storage for its blocks. A
      new public `BlockStorage` trait defines what that storage must support.
      
      - `Bitset` is now `Bitset<S: BlockStorage = Vec<usize>>`, so every
      existing user keeps `Vec<usize>` storage.
      - The trait is implemented for `Vec<usize>`, `SmallVec<[usize; N]>` and
      `ArrayVec<usize, N>`. `turbo-bitset` now depends on `smallvec` and
      `arrayvec` unconditionally.
      - All `Bitset` methods and operators, plus `Encode`, `Decode` and
      `ShrinkToFit`, work with any storage. Set operations require both sides
      to use the same storage. The `turbo-tasks` integrations remain on the
      default `Bitset`.
      - The encoding doesn't depend on the storage, so bytes written with one
      storage decode into any other.
      - With `ArrayVec`, operations that would need more than its capacity of
      `N` blocks panic. Decoding a set that doesn't fit returns a
      `DecodeError`.
      - `shrink_to_fit` only touches the storage when that frees capacity. An
      `ArrayVec` or an inline `SmallVec` is left unchanged.
      
      ### Why?
      
      This lets small sets use inline storage where that helps, without making
      every `Bitset` user change its storage type.
      
      ### How?
      
      - **Bounded storage:** when an operation would exceed an `ArrayVec`'s
      capacity, empty blocks at either end of the storage are dropped first.
      This fixes a case where an insert at the back panicked although the bits
      fit, because earlier growth at the front had filled the capacity with
      zero blocks.
      - **`intersection`:** builds its result with `FromIterator`, so a `Vec`
      keeps its exact-size allocation.
      - **Inlining:** only the small methods of the non-generic `Vec` storage
      are marked `#[inline]`. The generic `SmallVec` and `ArrayVec`
      implementations and `Iter::next` have no annotation; removing those had
      no effect on the benchmark binary (see below).
      - **Tests:** the shared semantic tests run for all three storages. New
      tests cover `ArrayVec` overflow and decode errors, `SmallVec`
      inline/spill behaviour, `shrink_to_fit`, zero-capacity storage, and
      encoding equality across storages. The benchmarks gain cases for
      `SmallVec` and `ArrayVec`.
      
      ### Verification
      
      - `cargo fmt --check -p turbo-bitset -p turbo-tasks -p turbopack-core`
      - `cargo clippy -q -p turbo-bitset -p turbo-tasks -p turbopack-core -p
      next-api --all-targets -- -D warnings`
      - `RUSTDOCFLAGS="-D warnings" cargo doc -q --no-deps -p turbo-bitset -p
      turbopack-core`
      - `cargo check -q -p next-api`
      - `cargo test -q -p turbo-bitset`
      - `cargo test -q -p turbo-tasks --lib`
      - `cargo test -q -p turbopack-core --lib`
      - `cargo test -q -p turbopack-tests --test snapshot` (no snapshot
      changes)
      - `cargo bench -q -p turbo-bitset --bench mod -- --test
      'bitset/storage_'` (216 cases)
      - `cargo run -q --release -p turbo-bitset --example sizes` gives output
      identical to before this change.
      - Not run: a 32-bit cross-check, because the `i686-unknown-linux-gnu`
      standard library is not installed locally. The test and benchmark
      changes avoid assuming a 64-bit `usize`.
      
      ### Performance caveats
      
      I compared release benchmark binaries for the previous `Vec`-only
      implementation and this change. Each side was built in its own target
      directory, I checked that the binary hashes differ, and the runs
      alternated old/new/new/old.
      
      - Before the final storage changes, the full comparison (336 cases)
      averaged **0.992×** of the old timings.
      - Those final changes switched `intersection` to `collect` and added
      `#[inline]`. After them, a focused rerun of 84 previously slower cases
      averaged **1.040×**:
      
      | Group | New / old (geomean) |
      | --- | ---: |
      | `intersection` | 0.907 |
      | `union` | 0.974 |
      | `contains` | 1.049 |
      | `insert` | 1.057 |
      | `iter` | 1.112 |
      | `from_iter` | 1.165 |
      
      - **`iter` and `contains`:** some inputs remain slower even though their
      normalized hot-loop instructions are the same in both binaries. The
      cause is unresolved.
      - **Empty `from_iter`:** about 3 ns becomes about 5 ns because of an
      extra out-of-line call.
      
      ### `#[inline]` annotations
      
      At `17be1d5e`, which annotated `Iter::next` and every `BlockStorage`
      method, I compared builds with and without all 43 of those annotations:
      full `mod` bench, 768 cases, runs alternating with/without/without/with,
      separate target dirs, release profile (thin LTO, one codegen unit).
      
      - Without any of them, the timings were **1.091×** overall (1.086× and
      1.095× in the two pairs). The same binary run twice drifted 1.024× and
      1.033×, but per group the same-binary drift reached about 30%, so this
      is a shared-VM microbenchmark trend, not a proven whole-build effect.
      - Removing only the annotation on `Iter::next`, or only the 28 on the
      generic `SmallVec`/`ArrayVec` implementations, gives a bench binary
      **byte-identical** to the annotated one.
      - Removing the 14 on the `Vec` implementation reproduces the whole
      difference. Without them, `Vec`'s `with_capacity` and `resize` wrappers
      remain separate functions in the binary, even with thin LTO.
      - So only the `Vec` annotations are kept. The bench binary of this PR's
      tip is byte-identical to the one built at `17be1d5e`.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet b56269ed-2145-4f30-b0fe-dc9762520521 -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarVercel Fleet <fleet@vercel.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      4bb4e8f1
    • Tobias Koppers's avatar
      Create cache directory before persisting Chrome DevTools workspace UUID (#100802) · b35fb85d
      Tobias Koppers authored
      ### What?
      
      When the dev server answers the Chrome DevTools workspace request
      (`/.well-known/appspecific/com.chrome.devtools.json`) and there's no
      persisted UUID yet, it now creates `<distDir>/cache` before writing
      `chrome-devtools-workspace-uuid`.
      
      ### Why?
      
      The UUID was written with a bare `writeFile`. If the cache directory
      didn't exist at the time of the first DevTools request (e.g. it was
      removed while `next dev` was running), the write failed with `ENOENT`.
      That logged the "needs to be reconnected after the next page reload"
      warning and kept the UUID in memory only, so the next server process
      generated a new UUID and the DevTools workspace had to be reconnected.
      
      On a normal startup the directory usually already exists because other
      startup writers create it, which is why this rarely shows up.
      
      ### How?
      
      - The directory is created recursively inside the existing `try/catch`.
      If creating the directory or writing the file fails (e.g. an unwritable
      path), the endpoint still responds with an in-memory UUID and logs the
      existing warning.
      
      **Test:** a dev-only e2e test (`// @force-gate dev`) in
      `test/e2e/chrome-devtools-workspace/`, using a dedicated fixture:
      - It waits for the asynchronous startup writes into the cache directory
      (`.rscinfo`, plus `next-devtools-config.json` with webpack), then
      removes the directory.
      - It then checks the endpoint returns a UUID, that the same UUID is on
      disk, and that no persistence warning is logged. After restarting the
      server, the same UUID must be returned.
      - The fixture disables the Turbopack filesystem cache so it can't
      recreate the directory mid-test.
      
      ### Verification
      
      - The new test fails without the fix and passes with it under
      `test-dev-turbo` and `test-dev-webpack`.
      - The existing `test/e2e/chrome-devtools-workspace/` suites still pass
      in dev (Turbopack and webpack) and in `test-start-turbo`.
      - Manual check: when the cache path is a regular file, so the directory
      can't be created, the endpoint still returns a UUID and logs the warning
      instead of crashing.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet f94f85f4-f8af-450a-a1ca-28243552f5f0 -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      b35fb85d
    • Chad Hietala's avatar
      examples: add eve example (#100758) · 94ffce78
      Chad Hietala authored
      ### What?
      
      This PR adds a new example, `examples/eve`. The example runs an
      [eve](https://eve.dev) agent and a Next.js App Router app as one
      project. It uses the `eve/next` integration.
      
      <img width="1300" height="747" alt="image"
      src="https://github.com/user-attachments/assets/18c99c82-53cc-42d6-ad44-9ef153516f56"
      />
      
      
      ### Why?
      
      Next.js does not have an example that shows how to add an eve agent to
      an app. This example gives a minimal starting point.
      
      You can create the example with `create-next-app --example eve`. You can
      deploy it with the Deploy button. The agent and the app use the same
      origin. They deploy as one Vercel project.
      
      ### How?
      
      **`next.config.ts`**
      
      - The `withEve()` function wraps the Next.js config.
      - `withEve()` puts the agent from `agent/` at `/eve/v1/*`. This path is
      on the same origin as the app.
      - When you run `next dev`, the eve dev server starts with Next.js.
      Next.js sends the eve routes to the eve dev server.
      
      **`agent/`**
      
      - `agent.ts` sets the model. The agent connects to the model through
      Vercel AI Gateway.
      - `instructions.md` contains the system prompt. The agent is a weather
      assistant.
      - `tools/get_weather.ts` is a typed tool. It uses a `zod` schema for the
      input. It gives fake weather data.
      - `channels/eve.ts` sets the auth policy for browser requests. The
      policy uses `vercelOidc()`, `localDev()`, and `none()`.
      
      **`app/chat.tsx`**
      
      This file is a Client Component. It uses the `useEveAgent` hook from
      `eve/react`. The component does these tasks:
      
      - It shows the messages as they stream in.
      - It shows the tool calls.
      - It sends new messages into a turn that is still running ("steer").
      - It stops a turn that is still running.
      - It starts a new session.
      - It prewarms the agent when the user types.
      
      **`README.md`**
      
      The README tells you how to:
      
      - Set the model key (`AI_GATEWAY_API_KEY` or Vercel OIDC).
      - Run the app in development.
      - Build the app for production. You must run `eve build` before `next
      build`.
      - Deploy the app with the Deploy button.
      
      You must use Node.js 24 or later.
      
      ### Security
      
      The channel uses `none()`. Because of this, a deployment from the Deploy
      button accepts anonymous requests. Any person who has the URL can use
      the agent. These requests use the AI Gateway credits of the person who
      deployed the app.
      
      The README gives this warning. It also gives a link to the eve auth
      guide.
      
      ---------
      Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
      94ffce78
    • Luke Sandberg's avatar
      Use fixed encoding for our 'id' types (#100764) · 6890cef0
      Luke Sandberg authored
      Varint encoding works well for things like lengths/indicies which are
      naturally 'zero biased' but many of our 'id' types are not like that
      
      Switch them to use a fixed encoding
      
      This includes: 
      
      * `TaskId` mostly 5 bytes before, now 4 bytes always
      * `CellId` always 5 bytes before, now 4 bytes always
      * `RawVc` always 9 bytes before, 8 bytes now
      * `FunctionId` mostly 3 bytes before, now 2 bytes
      * `ValueTypeId` mostly 3 bytes before now 2 bytes
      * `TraitTypeId` transformed to a `NonZeroU8` so it always takes the
      fixed int encode path naturally
      
      In principle it is possible that we might still benefit from varint
      encoding if most of the uses of these ids were biased towards smaller
      values, but at least in practice this isn't the case.
      
      ### Results
      
      Measured on a large app comparing to canary
      
      | | canary | this PR | change | per-round range |
      |---|---|---|---|---|
      | **Cache size after cold build** | 2.646 GB | 2.546 GB | **−3.8%** |
      −3.8 to −3.7% |
      | **Cache size after warm build** (compacted) | 2.628 GB | 2.527 GB |
      **−3.8%** | −3.9 to −3.7% |
      | **Warm build user CPU** (mostly decoding) | 43.8s | 42.2s | **−3.7%**
      | −5.1 to −2.3% |
      | Cold build user CPU | 482.6s | 483.0s | +0.1% | −1.4 to +1.0% |
      | Wall time, cold / warm | 75.3s / 31.2s | 76.1s / 31.4s | within noise
      | |
      | Peak RSS, cold / warm | | | −0.2% / −0.8% | |
      6890cef0
    • next-js-bot[bot]'s avatar
    • Jan Kassens's avatar
      [testmode] Fix compressed HTTP responses with test proxy (#100805) · e6478e14
      Jan Kassens authored
      ## Summary
      
      Fix compressed responses received by Node HTTP clients when
      `experimental.testProxy` is enabled. Requests outside a test context and
      proxy `continue` responses now use native HTTP passthrough, preserving
      the original compressed bytes and headers.
      
      Normalize stale `Content-Encoding` and `Content-Length` headers when
      serializing fetched responses with supported compression encodings,
      including cloned fetch responses. Preserve explicitly constructed mock
      responses as supplied, including deliberately compressed bytes. Handlers
      that construct a response with a modified body must update its headers
      themselves. Preserve bodyless responses such as HEAD so their
      representation metadata remains available.
      
      Add regression coverage for chunked responses and compressed bodies
      whose decoded length is shorter or longer than the upstream content
      length, across native passthrough, proxy continue, fetched responses,
      and modified responses. Also cover explicitly compressed mocks,
      fetched-response clones, unsupported encodings, and HEAD metadata.
      
      ## Verification
      
      - All 36 testmode integration tests passed in development mode with
      webpack, using the published native binding because the local native
      build has an incompatible lockfile API.
      - Confirmed the standalone gzip reproduction fails against the unchanged
      build and passes with native passthrough.
      
      <!-- NEXT_JS_LLM -->
      e6478e14
    • Steven's avatar
    • Jan Kassens's avatar
      [RFC] Remove worktree guidance from AGENTS.md (#100659) · 8b59e7dd
      Jan Kassens authored
      ## Summary
      
      Proposes repository-level worktree setup for Codex and Claude Code,
      replacing the worktree instructions in AGENTS.md. A shared script
      installs dependencies and builds Next.js with its workspace
      dependencies. Codex runs it through a local environment; Claude creates
      a detached HEAD worktree and runs the same setup.
      
      Claude cleanup preserves uncommitted changes and commits that are not
      reachable from a branch or tag. Codex's environment must be selected
      when starting a worktree chat.
      
      ## Verification
      
      - Checked creation, isolated setup, detached HEAD behavior, cleanup
      protections, and setup failure handling in a temporary Git repository
      with dependency installation and builds stubbed.
      - Formatting, ESLint, shell syntax, and configuration checks passed.
      - Full dependency installation and build were not run.
      
      <!-- NEXT_JS_LLM -->
      8b59e7dd
    • Aurora Scharff's avatar
      eval: resolve and classify the audit suite (#100748) · 433fe0ed
      Aurora Scharff authored
      The October pass@1 study left seven tasks in `audit` because their
      graders, framework contracts, or failures were not trustworthy enough to
      classify. This resolves every task: three repaired tasks move to
      regression, two valid competency tasks remain discriminatory, and two
      invalid public measurements are unpublished.
      
      ## Classification
      
      | Task | Before | Change and evidence | Final |
      | --- | --- | --- | --- |
      | `026-no-serial-await` | Generic JavaScript task with solution leakage
      and source-shape grading | Current score cannot support a Next.js
      competency claim | Unpublished; removed from runnable suites |
      | `029-use-cache-directive` | Missing Cache Components setup and
      incomplete flow verification | Requires Cache Components and verifies
      the cached read, form-bound action, shared tag, and two-argument
      revalidation as one flow. Gemini failed both scored treatments;
      confirmations were mixed | Competency |
      | `030-app-router-migration-hard` | Broad migration with incomplete
      coverage and unstable judges | Current score cannot distinguish
      migration ability from grader gaps | Unpublished; held out until split
      or substantially repaired |
      | `035-connection-dynamic` | Accepted `io()` for a real-request
      requirement and used three variable judge checks | Requires
      `connection()`, preserves the stable frame, and consolidates the
      request-specific behavior check. All 8 valid treatments passed |
      Regression |
      | `038-refresh-settings` | Grader did not connect the mutation, UI, and
      `refresh()` | Ties the complete Server Action flow together and rejects
      redirects. All 9 valid calibration results passed | Regression |
      | `041-optimize-ppr-shell` | Vague prompt and one
      implementation-oriented judge | Names the visible shell and
      independently revealing sections, keeps Cache Components enabled, and
      grades the rendered component tree. All 8 valid treatments passed |
      Regression |
      | `051-prefetch-until-navigation` | Broad source checks around
      navigation-stage prefetching | Scopes the title prefetch and deferred
      details to the destination. Frontier passed; Luna Base failed its scored
      attempt and both confirmations, while Luna AGENTS.md passed | Competency
      |
      
      The final suite contains 22 regression tasks and 7 competency tasks. No
      task remains in `audit`. `044-uses-nextjs` remains outside these suites
      because it measures framework preference for a0.
      
      ## Repaired-task results
      
      Pass@1 against the exact `16.5.0-canary.27` package:
      
      | Model | Treatment | `029` | `035` | `041` |
      | --- | --- | ---: | ---: | ---: |
      | Claude Opus 5.5 | Base | 1/1 | 1/1 | 1/1 |
      | Claude Opus 5.5 | AGENTS.md | 1/1 | 1/1 | 1/1 |
      | GPT-6 Sol | Base | 1/1 | 1/1 | 1/1 |
      | GPT-6 Sol | AGENTS.md | 1/1 | 1/1 | 1/1 |
      | Gemini 4 Argon | Base | 0/1 | 1/1 | 1/1 |
      | Gemini 4 Argon | AGENTS.md | 0/1 | 1/1 | 1/1 |
      | GPT-6 Luna | Base | 1/1 | 1/1 | 1/1 |
      | GPT-6 Luna | AGENTS.md | discarded | 1/1 | 1/1 |
      
      The discarded Luna `029` attempt timed out without a transcript and is
      not a model result. Diagnostic reruns do not change pass@1: Gemini Base
      passed one of two confirmations and repeated the same substantive
      failure once; Gemini AGENTS.md passed both confirmations. The two scored
      Gemini cells remain failed and should be reported as unstable.
      
      ## Validation
      
      - `pnpm prettier ... --check` on all changed files
      - `npx eslint --config eslint.config.mjs` on all changed graders
      - `pnpm eval --suite competency --dry`
      - `pnpm eval --suite regression --dry`
      - `git diff --check`
      
      Stacked on #100742, which adds suite selection and the classification
      protocol.
      
      <!-- NEXT_JS_LLM -->
      433fe0ed
    • Tobias Koppers's avatar
      turbo-tasks-backend: resolve task priority when creating child contexts (#100767) · a2fb5e3b
      Tobias Koppers authored
      ### What?
      
      `ExecuteContext::child_context()` in `turbo-tasks-backend` now reads the
      current task priority on the calling thread. The resulting
      `ChildExecuteContext` stores a priority that is already known, instead
      of an optional one.
      
      ### Why?
      
      Both users of `child_context()` hand the child context to
      `scope_bounded` helper threads:
      
      - the parallel path of `connect_children` (≥10k new children)
      - the parallel invalidation of output dependents
      
      Before this change the child context copied an override that is usually
      unset. On a helper thread, `get_current_task_priority()` then fell back
      to the task-local task state. That state only exists on the thread
      running the task, so helper threads got `TaskPriority::initial()`. Tasks
      scheduled or made dirty from those chunks (e.g. via
      `make_task_dirty_internal`) therefore got a priority that depended on
      which thread ran the chunk.
      
      ### How?
      
      The priority is resolved in `child_context()`, on the thread that
      creates the context. An explicit override still wins; otherwise the
      task-local priority is read before the work moves to another thread.
      Making the field non-optional means a child context can no longer carry
      an unresolved priority.
      
      Putting the fix in `child_context()` covers both parallel users, and any
      future one. Neither user relied on the late lookup, because the child
      context always runs on another thread. Paths that don't go parallel are
      unchanged.
      
      Verification:
      
      - `cargo check -p turbo-tasks-backend --all-targets`
      - `cargo clippy -p turbo-tasks-backend --all-targets`
      - `cargo nextest run -p turbo-tasks-backend` (329 passed)
      
      This PR does not add a regression test for priority on the parallel
      paths. Such a test could build on the existing
      `dirty_parent_priority_for_testing` hook used in
      `tests/invalidate_all.rs`.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 458ef681-a3c9-47b5-a9fe-b400713e9995 -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      a2fb5e3b
    • Will Binns-Smith's avatar
      Add server-only leak pass to next-bundle-optimizer (#100330) · 7812b031
      Will Binns-Smith authored
      ## Summary
      
      The bundle optimizer ranks client code by size, so it misses small
      modules that shouldn't be in the browser at all: a database schema, a
      token-signing helper, an agent's system prompt. This adds a
      size-independent leak pass to step 4 that walks every client-reachable
      module in the analyzer export and checks it against content heuristics.
      
      Matches are reported in a separate "Possible server-only leaks" section
      with route, shortest import chain, matched heuristics and compressed
      bytes. They stay out of the size ranking and deltas, and the agent
      leaves flagged modules and their import chains untouched in both modes,
      since moving them is the owner's call and a size metric can't verify it.
      
      The scan lives inline in SKILL.md rather than in a reference file. It
      runs on every invocation, and in eval runs the agent skipped a reference
      pointer in fix mode and missed a finding.
      
      Also rewords one existing sentence in step 4's Done line.
      
      Evals:
      
      - `agent-059-bundle-audit-server-leaks`: audit mode. Two leaks
      (prompt-like schema descriptions under `lib/server`, agent instructions
      reached through a shared util) sit well below a lodash import in size.
      Negative controls cover UI copy under
      `description`/`instructions`/`prompt` keys, a `NEXT_PUBLIC_` read and a
      `server-only` module used only by a Server Component.
      - `agent-060-bundle-fix-server-leaks`: fix mode on the same app. Checks
      the lodash fix still happens, the leaks are reported as unfixed, and
      none of the flagged modules or their importers are edited.
      
      ## Verification
      
      - `pnpm eval agent-059-bundle-audit-server-leaks`: `skills` passes,
      `baseline` and `agents-md` fail
      - `pnpm eval agent-060-bundle-fix-server-leaks`: `skills` passes,
      `baseline` and `agents-md` fail (both edit the flagged modules)
      - Not rerun: both evals after dropping the env-read case and the
      `/pricing` route from the fixtures
      
      <!-- NEXT_JS_LLM -->
      
      ---------
      Co-authored-by: 's avatarvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
      7812b031
    • Benjamin Woodruff ‮'s avatar
      Turbopack: Fix webpack loaders if source file exists in an additional root (#100744) · 73469204
      Benjamin Woodruff authored
      The webpack runner needs to compute the absolute path to the loader
      implementation, and it cannot compute it relative to the cwd if we're
      using additional roots.
      
      Adds this struct:
      
      ```
      /// An argument passed to the evaluated JavaScript.
      #[turbo_tasks::task_input]
      #[derive(Clone, Hash, Debug, PartialEq, Eq, Encode, Decode)]
      pub enum EvaluateArg {
          Vc(ResolvedVc<JsonValue>),
          /// Passed as a string: A path relative to [`EvaluateContext::cwd`] when both are on the same
          /// filesystem, otherwise an absolute system path (e.g. for an additional root).
          ///
          /// This is converted when the evaluation runs, so that machine-specific system paths aren't
          /// stored in task inputs or cells.
          Path(FileSystemPath),
      }
      ```
      
      The `Path` variant allows us to defer conversion to an absolute system
      path until after we've crossed the turbo-tasks boundary, right before we
      call the webpack loader.
      73469204
    • Benjamin Woodruff ‮'s avatar
      Turbopack: Auto-detect pnpm GVS and configure an additional root for it (#99758) · 7d91feca
      Benjamin Woodruff authored
      This implements auto-configuration (behind a flag for now) for pnpm 11+.
      
      pnpm 10 supports GVS, but `node_modules/.modules.yaml` is actually YAML
      on 10. 11 changes it to a JSON file, which lets us avoid pulling in a
      YAML parser. IMO, this is fine as GVS on pnpm 10 is very experimental
      (it seems like it doesn't play nicely with `packageExtensions`).
      
      TODO in future PRs:
      - bun, nub, aube support
      - figure out how to support `NODE_PATH` so that hoisting works for
      broken packages with phantom dependencies (users can work around this
      with `packageExtensions`, pnpm documents this problem in the GVS docs)
      - Switch on GVS for (most of) the Next.js e2e tests so that we have some
      good coverage of this feature.
      https://github.com/vercel/next.js/pull/100337
      7d91feca
    • Tobias Koppers's avatar
      Persist storage cache in Docker environments (#100790) · d054fe4a
      Tobias Koppers authored
      ### What?
      
      Next.js now persists its server-side storage cache in Docker
      environments, the same as other environments. This covers the RSC /
      Server Actions encryption key, preview-mode keys, and the development
      Chrome DevTools workspace identifier.
      
      ### Why?
      
      The shared storage-directory helper previously disabled `.next/cache`
      persistence whenever Docker was detected. As a result, Docker
      environments could not reuse cached RSC encryption secrets across
      separate key-generation processes.
      
      ### How?
      
      The shared helper now always resolves the cache directory beneath the
      configured dist directory. Because storage is always available, each
      consumer drops the now-unreachable fallback path and uses the existing
      cache read/write flow directly. Existing key validation, expiry-based
      rotation during builds, and `NEXT_SERVER_ACTIONS_ENCRYPTION_KEY`
      precedence are unchanged.
      
      Telemetry is intentionally unchanged: it has its own storage-location
      logic for CI and Docker, which already stores telemetry configuration in
      `.next/cache` there.
      
      ### Verification
      
      - Ran a focused probe against the updated source with Docker detection
      mocked. It confirmed RSC encryption-key cache write and reuse,
      expired-key handling for runtime and builds, explicit encryption-key
      precedence, and preview-key cache write and reuse.
      - `pnpm --filter=next types`
      - Not run: full Next.js integration tests.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 3a3e1bf2-4e32-499c-8f71-ae9dd2d64f16 -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      d054fe4a