1. 29 Oct, 2026 17 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.32 · 80d27553
      next-js-bot[bot] authored
      80d27553
    • Luke Sandberg's avatar
      Improve common errors in turbo-trace-server (#100862) · 2ad93490
      Luke Sandberg authored
      More than once i have been blocked by the the vscode sandbox when
      attempting to read a trace file, now we print the PermissionDenied error
      so this is easier to diagnose
      
      a client disconnect also gets a simpler error message, these are not a
      big deal
      2ad93490
    • Aurora Scharff's avatar
      docs: clarify use cache is unsupported in Proxy (#100842) · fc5ebd29
      Aurora Scharff authored
      ## Summary
      
      - document that Proxy does not transform `use cache` or `use server`;
      functions still execute, but directive semantics do not apply
      - explain that `use cache` output is neither cached nor deduplicated in
      Proxy and that `cacheLife` throws without a cache scope
      - clarify that hosting providers can replace the default cache handler
      or disable runtime storage, while concurrent calls can still be
      deduplicated
      - point Proxy users to an external cache or data store, or to a
      supported application context such as a Server Component or Route
      Handler
      
      Affected documentation:
      
      - `docs/01-app/01-getting-started/16-proxy.mdx`
      - `docs/01-app/03-api-reference/03-file-conventions/proxy.mdx` (also
      supplies the Pages Router Proxy reference)
      - `docs/01-app/03-api-reference/01-directives/use-cache.mdx`
      - `docs/01-app/03-api-reference/01-directives/use-server.mdx`
      
      Related to #85475.
      Finding: https://next-maintainer-agent.vercel.tools/agent-feedback/5487
      
      ## Verification
      
      - Prettier 3.6.2 check on the changed MDX files
      - `git diff --cached --check` before committing
      - Not run: test suite (documentation-only change)
      
      <!-- NEXT_JS_LLM -->
      
      ---------
      Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
      Co-authored-by: 's avatarJoseph <sephxd1234@gmail.com>
      fc5ebd29
    • Tobias Koppers's avatar
      Revert "perf(turbopack): canonicalize async loader availability" (#100898) · a14cbc44
      Tobias Koppers authored
      Reverts vercel/next.js#100705
      a14cbc44
    • Luke Sandberg's avatar
      Fix hangs and crashes for 204 responses from route handlers and deduped fetches (#100159) · 3478b30f
      Luke Sandberg authored
      ### What
      
      `new Response(body, { status })` throws `Invalid response status code
      204` for null body statuses (204, 205, 304) whenever `body` is non-null,
      and that includes an empty buffer. A few places buffer a response with
      `arrayBuffer()` and rebuild it, which turns a body-less response into an
      empty buffer:
      
      - **Route handler prerender with `cacheComponents`**
      (`app-route/module.ts`). The throw happened inside a `.then` callback
      whose rejection nothing handled, so the prerender promise never settled.
      Any route handler returning 204, including the auto-implemented
      `OPTIONS` handler, hung until the function timeout, and a GET returning
      204 hung `next build`. We hit this on nextjs.org: every `OPTIONS
      /feed.xml` logged an `unhandledRejection` and then a 60s `Vercel Runtime
      Timeout Error`.
      - **Serving a cached app route response**
      (`build/templates/app-route.ts`), which rebuilt the response from the
      stored body and returned a 500. This runs on Vercel too, right after
      generation, so fixing only the prerender path would have turned the
      timeouts into 500s.
      - **Fetches deduped through `workStore.pendingRevalidates`**
      (`patch-fetch.ts`). The origin response is buffered for any status, so
      when it was a 204, every waiting caller after the first threw.
      
      ### How
      
      - On the in-memory paths (the route handler prerender and both
      `pendingRevalidates` producers), check `body === null` on the original
      response and skip `arrayBuffer()` entirely, so nothing is read or
      allocated. The route handler prerender also now uses
      `.then().catch(reject)`, so a future throw there rejects instead of
      hanging.
      - Serving a cached route response checks the status with a new
      `isNullBodyStatus` helper. The stored format (`.body` file,
      `CachedRouteValue.body: Buffer`) stores a missing body as zero bytes, so
      only the status can tell them apart. I left the format alone because
      custom cache handlers and existing entries depend on it.
      
      The fetch cache itself only stores 200 responses, so a fetch cache hit
      and `createCachedPrerenderResponse` can't see a 204 and are unchanged.
      
      ### Tests
      
      - `use-cache-route-handler-only`: a GET returning 204. Without the fix,
      `next build` hangs on it and gets killed.
      - `use-cache-route-handler-only`: auto-implemented `OPTIONS` on a `'use
      cache'` route, deploy-only. `next start` answers non-GET/HEAD requests
      to prerendered routes with a 405 before the handler runs, while Vercel
      invokes the function, which is how production reached the prerender
      path. Not run locally.
      - `patch-fetch.test.ts`: two concurrent identical fetches during a
      foreground revalidate, with the origin returning 204. Without the fix,
      this throws.
      
      <!-- NEXT_JS_LLM -->
      3478b30f
    • Hendrik Liebau's avatar
      [test] Cover cache reuse after revalidation and failed writes (#100652) · 4ebb2b7a
      Hendrik Liebau authored
      The tests verify that an embedded runtime prefetch reuses a valid
      handler entry after tag revalidation invalidates the old Resume Data
      Cache entry. They also verify that a server action returns a shared
      value and completes its re-render when the producer's handler write
      fails.
      
      These tests cover existing behavior that the `use cache` wrapper rewrite
      in #100511 must preserve.
      4ebb2b7a
    • Jimmy Miller's avatar
      Turbopack: use analyzed references for fragment facades (#100852) · 79107ebd
      Jimmy Miller authored
      Use the same analyzed references for facade graph traversal and code
      generation so pruned evaluation fragments cannot leave dangling imports.
      
      Add a regression test for a client reexport of a side-effect-free
      barrel.
      79107ebd
    • Sam Selikoff's avatar
      fix(adapter): preserve revalidation for metadata prerenders (#100861) · 12469cdb
      Sam Selikoff authored
      Metadata routes like `robots.ts` and `sitemap.ts` were emitted as static
      files even when they had revalidation configured, so adapter deployments
      could never refresh them.
      
      Keep revalidating metadata as prerenders backed by app routes. Compute
      static-file eligibility once so the two output decisions stay in sync.
      
      Related to #100782.
      
      <!-- NEXT_JS_LLM -->
      12469cdb
    • Sebastian "Sebbie" Silbermann's avatar
      [ci] Pin deploy test deployments to Node.js 22.x (#100879) · 4c6a3fa4
      Sebastian "Sebbie" Silbermann authored
      Otherwise Vercel default for new projects is used which is latest
      Node.js. This could cause random breakages if not everything is future
      compatible.
      
      We can later use the same setup to configure runs to use newer Node.js
      versions (e.g. on a schedule to test future compat).
      
      ## Verification
      
      - Full deploy run:
      https://github.com/vercel/next.js/actions/runs/40861798132 -> [Example
      deployment with Node.js
      override](https://vercel.com/vtest314-next-adapter-e2e-tests/vtest314-e2e-tests/DVip99zHRvi6EVDiiFs7S6jcK97U)
      
      <!-- NEXT_JS_LLM -->
      
      ---------
      Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
      4c6a3fa4
    • Tim Neutkens's avatar
      create-next-app: remove App Router prompt and always use App Router (#100850) · 5a2d24ea
      Tim Neutkens authored
      `create-next-app` no longer asks "Would you like to use App Router?
      (recommended)". New projects always use the App Router.
      
      **Why**
      
      The App Router is the recommended default, and the interactive prompt
      only offered a way to pick the Pages Router by accident. A saved `app:
      false` preference from an earlier run also kept silently producing Pages
      Router projects.
      
      **Approach**
      
      - Remove the App Router toggle prompt and set `opts.app = true` unless
      `--no-app` or `--api` is passed.
      - Drop `app` from the defaults/preferences display, so the "recommended
      defaults" and "reuse previous settings" summaries no longer list "App
      Router" / "Pages Router".
      - Saved `app` preferences are ignored. `--no-app` remains as the
      explicit opt-out, so the existing Pages templates and their tests are
      unchanged.
      
      **Validation**
      
      - `prompts.test.ts`: removed the App Router prompt from the customize
      flow; the "reuse previous settings" test with a saved `app: false` now
      expects an `app/` directory.
      - Type-checked `packages/create-next-app/index.ts` with no new errors.
      The create-next-app e2e tests were not run locally.
      
      **Docs**
      
      Removed the prompt line and "App Router" from the recommended defaults
      summary in the installation guide and the `create-next-app` CLI
      reference.
      
      ---------
      Co-authored-by: 's avatarroboeve[bot] <311457182+roboeve[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTim Neutkens <6324199+timneutkens@users.noreply.github.com>
      5a2d24ea
    • Niklas Mischkulnig's avatar
      next-custom-transforms: Optimize server-reference transform output (#100637) · 94ea1c21
      Niklas Mischkulnig authored
      This will eventually allow better tree shaking
      
      Before:
      ```js
      const $$RSC_SERVER_CACHE_0_INNER = async function cached() {
        return expensive()
      }
      
      export var $$RSC_SERVER_CACHE_0 = reactCache(function cached() {
        return cache('default', id, 0, $$RSC_SERVER_CACHE_0_INNER, [])
      })
      
      registerServerReference($$RSC_SERVER_CACHE_0, id, null)
      Object.defineProperty($$RSC_SERVER_CACHE_0, 'name', { value: 'cached' })
      ```
      
      After:
      ```js
      const $$RSC_SERVER_CACHE_0_INNER = async function cached() {
        return expensive()
      }
      
      export var $$RSC_SERVER_CACHE_0 =
      	/*#__PURE__*/Object.defineProperty(
      	/*#__PURE__*/registerServerReference(
      	/*#__PURE__*/reactCache(function cached() {
      		return cache('default', id, 0, $$RSC_SERVER_CACHE_0_INNER, [])
      	}), id, null), 'name', { value: 'cached' })
      ```
      94ea1c21
    • Niklas Mischkulnig's avatar
      Turbopack: fix trailing-slash package root resolution (#100726) · b6ac0b53
      Niklas Mischkulnig authored
      ### What?
      
      Fix trailing-slash package-root resolution in Turbopack, including
      dynamic CommonJS requests with an empty runtime suffix.
      
      ### Why?
      
      The package-root result could be keyed as a bare package request even
      when the request included a trailing slash. Dynamic module contexts then
      lacked the slash-root key and threw `MODULE_NOT_FOUND` for a valid
      package entry. Exact trailing-slash requests could also resolve the same
      folder twice through overlapping root and relative-subpath paths.
      
      ### How?
      
      Resolve matching package roots once while preserving distinct bare and
      trailing-slash request keys. Only use relative-subpath resolution for
      patterns that can match deeper paths, leaving package-exports handling
      unchanged.
      
      Add keyed Rust coverage for main/index fallback, exports and dynamic
      patterns, plus a loader-free execution fixture that distinguishes the
      package main from index and checks real and missing subpaths.
      
      ### Verification
      
      - Confirmed the execution regression fails on the unfixed resolver and
      passes with the correction.
      - `cargo nextest run -p turbopack-tests --test execution -E
      'test(resolving)'` — 33 fixtures passed.
      - `cargo test -p turbopack-core --lib` — 198 passed; 2 existing ignored
      benchmarks.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 21b5a5ed-fae3-4261-8b72-44936c636deb -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      b6ac0b53
    • Tobias Koppers's avatar
      Show dev overlay errors before the indicator state is known (#100629) · a0e61716
      Tobias Koppers authored
      ## Summary
      
      In development, the dev overlay renders nothing until the HMR `sync`
      message arrives. That message tells the client whether the dev indicator
      is disabled, and the client waits for it so a disabled indicator doesn't
      briefly appear. The error overlay (redbox) sat behind the same check,
      though. If `sync` was delayed or lost, compile and runtime errors
      already reached the client state but no redbox was shown.
      
      This PR keeps the indicator-readiness check only for the indicator UI,
      meaning the devtools indicator and its panels. The error overlay and the
      contexts it needs now render independently of it, so errors show as soon
      as they are known. When `sync` arrives normally, the indicator behaves
      the same as before.
      
      #100628 removes the server-side cause of a delayed `sync` (waiting on
      the npm registry version check). This change is independent and protects
      the overlay from any other delay.
      
      A regression test uses Playwright websocket routing to withhold only the
      `sync` message. For both the app and pages router, it checks that a
      module-not-found error still shows the redbox and that the devtools
      indicator stays hidden.
      
      ## Verification
      
      Run locally with Turbopack dev and webpack dev:
      
      - New `test/development/app-dir/dev-overlay-redbox-before-sync`: fails
      without this change (no redbox) and passes with it.
      - `test/development/acceptance/ReactRefreshLogBox-builtins.test.ts`
      -
      `test/development/acceptance-app/rsc-build-errors-react-apis-1.test.ts`
      - `test/development/dev-indicator/dev-indicator.test.ts`
      - `test/development/app-dir/dev-indicator/hide-button.test.ts`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 64c837ee-843c-4c4b-b256-57dd903babf5 -->
      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>
      a0e61716
    • next-js-bot[bot]'s avatar
      Update font data (#100863) · 88d72694
      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>
      88d72694
    • 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 4 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