1. 30 Oct, 2026 29 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.35 · 6d4dc60a
      next-js-bot[bot] authored
      6d4dc60a
    • Aurora Scharff's avatar
      docs: clarify blocking route response status (#100191) · d76ff78c
      Aurora Scharff authored
      ## What?
      
      - Correct examples that conflated not-found, forbidden, or unauthorized
      UI with a guaranteed HTTP status.
      - Clarify that `instant = false` does not buffer the HTTP response or
      guarantee a later `404`.
      - Update the streaming and status-code docs for Cache Components while
      keeping the existing `notFound()` example.
      - Clarify that HTML-limited bots wait for `generateMetadata`, after
      which the page can continue streaming.
      
      ## Why?
      
      The existing docs tied status commitment too closely to visible HTML and
      Suspense. With Cache Components, an empty prerendered shell can start
      the response before request-time rendering resumes. A later
      `notFound()`, `forbidden()`, or `unauthorized()` call renders its
      fallback UI and adds `noindex`, but it cannot change a committed `200`
      status.
      
      Proxy can provide an early request-time status. Redirects configured in
      `next.config.js` also run before page rendering and can return an HTTP
      redirect response.
      
      Supersedes: #99801
      
      Related implementation PR: #99218
      
      Related Discussion: #100192
      
      ## Testing
      
      - Prettier on all changed files
      - MDX ESLint on all changed files
      - `git diff --check`
      d76ff78c
    • Joseph's avatar
      docs: note per-route cost of boundary files, cached Route Handler checks, and… · a7a0dca7
      Joseph authored
      docs: note per-route cost of boundary files, cached Route Handler checks, and per-instance rate limits (#100985)
      
      ## Summary
      
      - `not-found.mdx`, `forbidden.mdx`, `unauthorized.mdx`: each of these
      files is sent with every route under its segment, even when the route
      never calls `notFound()`, `forbidden()`, or `unauthorized()`, and the
      Client Components it imports load on those pages. For the root
      `app/not-found.js`, that is every page of the app.
      - `backend-for-frontend.mdx`, rate limiting: a counter kept in memory
      applies per server instance and resets on restart.
      - `backend-for-frontend.mdx`, access to protected resources: a response
      cached with `Cache-Control: public` can be served by a CDN without
      running the handler, so its checks do not apply to cache hits.
      
      Commits:
      
      - docs: note boundary files ship with every route, cached Route Handler
      responses skip checks, and in-memory rate limits are per instance
      
      <!-- NEXT_JS_LLM -->
      a7a0dca7
    • Aurora Scharff's avatar
      docs: clarify unstable_cache cross-deployment persistence (#100983) · 07bf5809
      Aurora Scharff authored
      ## Summary
      
      - clarify that `use cache` replaces `unstable_cache` for most use cases,
      while `unstable_cache` remains appropriate for non-`fetch` data that
      must persist across deployments
      - link the reported agent feedback:
      https://next-maintainer-agent.vercel.tools/agent-feedback/5665
      
      ## Related guidance reviewed
      
      - `docs/01-app/03-api-reference/01-directives/use-cache.mdx` already
      recommends `unstable_cache` for cross-deployment persistence of
      non-`fetch` data
      - `docs/01-app/03-api-reference/01-directives/use-cache-remote.mdx`
      already documents the same exception for remote cache entries
      - `docs/01-app/02-guides/migrating-to-cache-components.mdx` already
      states that migrating `unstable_cache` is optional and explains the
      persistence difference
      
      ## Verification
      
      - `pnpm exec prettier --ignore-path .prettierignore --check
      docs/01-app/03-api-reference/04-functions/unstable_cache.mdx`
      - `pnpm exec eslint --config eslint.config.mjs
      docs/01-app/03-api-reference/04-functions/unstable_cache.mdx`
      - `pnpm lint` (blocked by nine pre-existing unused Turbo Tasks findings
      on canary)
      
      <!-- NEXT_JS_LLM -->
      07bf5809
    • Aurora Scharff's avatar
      eval: allow static headings in prefetch-stage results (#100984) · 18415429
      Aurora Scharff authored
      ## Summary
      
      `049-prefetch-stage` can reject a solution for keeping a static “Related
      products” heading in the App Shell, even when the related-product data
      stays outside it and is ready before navigation. This affected six saved
      attempts in the [Terra
      results](https://github.com/vercel/next-evals-oss/pull/161).
      
      Clarify the two grading criteria to allow a static heading, section
      wrapper, or loading fallback. Keep the existing requirements for
      prefetching, caching, and excluding related-product items from the
      shell.
      
      ## Verification
      
      - Reviewed all eight saved `049` patches and their recorded
      production-payload checks.
      - Formatting, ESLint, and `git diff --check` pass.
      - Eval typechecking could not start because local dependencies are
      missing `vitest` types.
      - No model or judge reruns; existing scores are unchanged.
      
      <!-- NEXT_JS_LLM -->
      18415429
    • Luke Sandberg's avatar
      turbopack: only add the Pages client entry when Pages routes exist (#100896) · 889deb0a
      Luke Sandberg authored
      ## Summary
      
      Only add the Pages Router client entry to the whole-app module graph
      when Pages Router endpoints will be emitted. Reuse the existing `/_app`
      endpoint condition.
      
      App Router–only builds otherwise resolve, parse, and analyze the Pages
      client graph without emitting it. Pages and mixed-router builds keep
      their existing entry.
      
      ## Verification
      
      - Pages-only change compiles independently (`cargo check -p next-api`).
      - App-only fixture graph: 1,074 → 955 modules. Mixed fixture builds and
      serves its Pages route.
      
      Separate from the AST cleanup in #100871; these PRs are independent.
      
      <!-- NEXT_JS_LLM -->
      
      <!-- I AM A HUMAN AUTHOR -->
      
      <!-- fleet 20689ccb-eff4-4cad-b89e-beeccbd8caa3 -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      889deb0a
    • Luke Sandberg's avatar
      turbopack: drop ASTs of tree-shaken modules (#100871) · 6198e2a7
      Luke Sandberg authored
      ## Summary
      
      Release parsed ASTs of tree-shaken modules during binding-usage
      analysis. Analysis retains ASTs for code generation to consume and
      release, but these modules never reach codegen.
      
      Add `Vc::drop_content_hint()` to resolve a reference with normal
      output-dependency tracking, then drop the cell content without reading
      or recomputing missing content. Binding-usage analysis calls a default
      no-op `Module::drop_code_gen_data_hint()` for unused modules; ecmascript
      modules drop their parse result. Cleanup runs only for the whole-app
      graph and adds no extra tasks.
      
      ## Verification
      
      - 1,283 Rust tests and 111 production tests pass on the AST-only change.
      - Mixed fixture releases 43 resident ASTs; all 61 compared JS/HTML/CSS
      files match the baseline.
      
      Independent companion: #100896 (Pages entry).
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 20689ccb-eff4-4cad-b89e-beeccbd8caa3 -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
      6198e2a7
    • Hendrik Liebau's avatar
      [test] Cover cache reuse after failed handler writes (#100976) · 4fed142e
      Hendrik Liebau authored
      The tests verify that a request reuses its generated entry after its
      cache handler write fails. The next cached invocation starts in a later
      task, after failed-write cleanup has completed, so pending generation
      cannot satisfy the assertion by itself.
      
      The background revalidation test verifies that a later stale cache hit
      retries a failed cache handler write and persists a replacement entry.
      These cases extend the joining-action failure coverage added in PR
      #100652 and protect the cache coordination changes in PR #100511.
      4fed142e
    • Will Binns-Smith's avatar
      Bundle Analyzer Agent Skill: Add Lodash deduplication eval (#99180) · edd20185
      Will Binns-Smith authored
      ## Summary
      
      Add a duplicate-Lodash eval with full imports at different versions in
      the app and local legacy widget. Require one resolved Lodash version,
      preserved status labels, and reduced cold browser JavaScript within a
      170,000-byte budget.
      
      Keep both text transformations in the browser through a Client
      Component. Require invocation of `next-bundle-optimizer` in the skills
      treatment.
      
      ## Verification
      
      - Root and eval TypeScript checks pass on the rebased stack.
      - Formatting, focused ESLint, and local setup/transcript checks pass.
      - Remote agent evals not rerun after these updates.
      - Bootstrap build blocked by a registry 401 while resolving
      `@pnpm/exe@10.33.0`.
      
      <!-- NEXT_JS_LLM -->
      
      <!-- fleet d7bdbc2b-b0bc-4591-99eb-dccb0fa49c73 -->
      
      <!-- fleet ea768377-d71c-4a15-90b2-f4d50d4f6a1c -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarWill Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
      edd20185
    • Will Binns-Smith's avatar
      Bundle Analyzer Agent Skill: Add server Markdown eval (#99179) · 2685731b
      Will Binns-Smith authored
      ## Summary
      
      Add a Markdown/highlighting eval that preserves rendered release notes
      while reducing cold browser JavaScript below 150,000 bytes.
      
      Use the shared bundle-optimizer measurement hooks and require invocation
      of `next-bundle-optimizer` in the skills treatment.
      
      ## Verification
      
      - Root and eval TypeScript checks pass on the rebased stack.
      - Formatting, focused ESLint, and local setup/transcript checks pass.
      - Remote agent evals not rerun after these updates.
      - Bootstrap build blocked by a registry 401 while resolving
      `@pnpm/exe@10.33.0`.
      
      <!-- NEXT_JS_LLM -->
      
      <!-- fleet d7bdbc2b-b0bc-4591-99eb-dccb0fa49c73 -->
      
      <!-- fleet ea768377-d71c-4a15-90b2-f4d50d4f6a1c -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarWill Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
      2685731b
    • Will Binns-Smith's avatar
      Bundle Analyzer Agent Skill: Add browser initial-load eval (#99178) · 7ca8d66d
      Will Binns-Smith authored
      ## Summary
      
      Add a click-gated CodeMirror eval that measures cold browser JavaScript
      before and after optimization. Require lazy loading, preload on hover,
      working editing, and a 200,000-byte initial-load budget.
      
      Share measurement and setup helpers under `evals/lib/bundle-optimizer/`.
      Require invocation of `next-bundle-optimizer` in the skills treatment.
      
      ## Verification
      
      - Root and eval TypeScript checks pass on the rebased stack.
      - Formatting, focused ESLint, and local setup/transcript checks pass.
      - Remote agent evals not rerun after these updates.
      - Bootstrap build blocked by a registry 401 while resolving
      `@pnpm/exe@10.33.0`.
      
      <!-- NEXT_JS_LLM -->
      
      <!-- fleet d7bdbc2b-b0bc-4591-99eb-dccb0fa49c73 -->
      
      <!-- fleet ea768377-d71c-4a15-90b2-f4d50d4f6a1c -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarWill Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
      7ca8d66d
    • Luke Sandberg's avatar
      Turbopack: use memchr3 for source position scanning and count astral chars as… · bd824641
      Luke Sandberg authored
      Turbopack: use memchr3 for source position scanning and count astral chars as two UTF-16 columns (#100919)
      
      ## Summary
      
      Turbopack's sectioned source maps compute each section's `offset` with
      `SourcePos::update`. It used to decode the generated code one UTF-8
      character at a time. That loop was slow, and it counted a 4-byte
      (non-BMP) character such as `🦀` as one column even though source-map
      columns are UTF-16 code units, where it takes two. So any section that
      started after an astral character on the same line got an offset column
      that was too small.
      
      `SourcePos::update` now works like the line index in `next-code-frame`'s
      highlighter:
      - `memchr3` finds line-terminator candidates (`\n`, `\r`, and the `0xE2`
      lead byte of U+2028/U+2029). The JS terminator semantics are kept:
      `\r\n` counts as one terminator, and only `E2 80 A8` / `E2 80 A9` count
      as line/paragraph separators.
      - Only the text after the last terminator affects the column, so only
      that segment is counted. A small `utf16_len(&[u8])` helper counts its
      UTF-16 units byte by byte: continuation bytes count 0, 4-byte lead bytes
      count 2, everything else counts 1. This is exact for UTF-8, safe on
      arbitrary bytes, and needs no `unsafe` or new dependency. A TODO points
      at switching to `simd-utf16-len` once it gains a byte-slice API
      (SyMind/simd-utf16-len#22).
      
      `memchr` was already a workspace dependency; `turbopack-core` now uses
      it too.
      
      `Code::generate_source_map_ref` calls `SourcePos::update` once per rope
      chunk, so its docs and `SourcePos::update`'s docs now state the contract
      this relies on: each chunk must be self-contained text, and a UTF-8
      sequence or a `\r\n` must not be split across chunks or mapping
      positions. Splitting one is a bug in the code that built the rope, and
      can produce wrong offsets. It is not memory-unsafe. Text built from
      `&str` already meets this contract in practice. Documenting it covers
      the concern that chunk boundaries could split terminators, without
      adding scanner state.
      
      Tests cover:
      - ASCII, BMP and astral characters;
      - `\n`, `\r`, `\r\n`, U+2028/U+2029, and neighbouring `0xE2` characters
      that are not separators;
      - incremental updates;
      - `utf16_len` against `str::encode_utf16`;
      - a `CodeBuilder` test with an astral character before a mapped section
      on the same line.
      
      ## Verification
      
      - `cargo test -p turbopack-core --lib`
      - A scanner-only micro-benchmark (synthetic ~1 MiB inputs, a noisy
      machine, not an end-to-end build) showed several-times higher throughput
      on newline-dense and minified ASCII. Text dense in U+20xx punctuation
      sees little benefit.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 8a1a11e5-9ce4-4f06-b7cb-50485f329e62 -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      bd824641
    • Niklas Mischkulnig's avatar
      test: properly gate some cache-component tests (#100828) · ad2c5b3e
      Niklas Mischkulnig authored
      Don't use `decribe.skip`, so that these tests at least still run in the
      non-cache-components mode.
      
      Except for 3 files, these were already listed in
      test/cache-components-tests-manifest.json
      
      I am confused whether we are supposed to use `@gate` or that manifest
      now. But that is another preexisting question
      
      This hid the failure in https://github.com/vercel/next.js/pull/100830
      ad2c5b3e
    • Shohei Maeda's avatar
      Handle cancellation errors during response clone cleanup (#100961) · 75718952
      Shohei Maeda authored
      ## Summary
      
      A response body can fail after `fetch()` resolves, for example when an
      upstream connection closes. Even if the caller catches the body-read
      error, garbage-collection cleanup of an unused response clone can call
      `cancel()` on its already-errored stream.
      
      That cancellation rejects, and the existing `.then(noop)` leaves the
      rejection unhandled. Depending on the runtime’s unhandled-rejection
      handling, this can terminate the process.
      
      Use `.catch(noop)` to handle cancellation failures during cleanup. The
      original body-read error still reaches the caller.
      
      Related: https://github.com/vrv/vercel-runtime-cache-cancel-repro
      75718952
    • Tobias Koppers's avatar
      next-napi-bindings: keep issue-backed client update errors recoverable (#100924) · 65e4a5ed
      Tobias Koppers authored
      ## Summary
      
      When `node_modules/next` is briefly missing (e.g. during a concurrent
      package install), `get_next_package` emits a `MissingNextFolderIssue`
      and also returns an error. The server-changed subscription already
      handles this: it uses `strongly_consistent_catch_collectables` and
      reports the Issue. The client-changed subscription
      (`endpoint_client_changed_subscribe`) propagated the error instead, so
      `subscribe` turned it into a `TurbopackInternalError` and printed
      `FATAL: An unexpected Turbopack error occurred: Next.js package not
      found`.
      
      With this change, the client-changed subscription reads
      `endpoint_client_changed_with_issues_operation`, an operation that wraps
      `endpoint_client_changed_operation` with the error handling. On success
      it returns the client-changed `Completion` unchanged. On failure it
      reads that operation's issues using the endpoint's issue filter: if an
      Error-severity issue explains the failure, it returns a new
      `Completion`, because the server subscription already surfaces the
      Issue; other errors still propagate. Issues are read only on the failure
      path, so the success path still doesn't depend on them. The subscription
      itself only does a strongly consistent read of the wrapper, as before.
      
      `test/development/app-dir/concurrent-install` covers this scenario.
      
      ## Verification
      
      - `cargo clippy -p next-napi-bindings`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 8482d6ce-bad2-4131-98e3-4a391357a1c9 -->
      
      ---------
      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>
      65e4a5ed
    • Tobias Koppers's avatar
      turbopack: report chunk group consistency errors instead of panicking (#100923) · be19b72b
      Tobias Koppers authored
      ## Summary
      
      Under eventual consistency, chunk group data from different graph
      versions can briefly be paired with each other. Two lookups still panic
      in that case. This PR makes both of them return errors, so the
      computation is retried once the data is consistent again.
      
      - **Merged-parent lookups.** `ChunkGroupKey::ident_str` resolved the
      parent of an `IsolatedMerged`/`SharedMerged` key with
      `keys.index(parent)`. Some callers render a key whose parent index comes
      from another (e.g. newer) `ChunkGroupInfo` than `keys`, for example
      `ChunkGroupInfo::get_index_of`'s debug failure path and
      `chunk_group_content_operation`. That panicked with
      `chunk_group_info.rs: index out of bounds: the len is 28 but the index
      is 29` during `next build`.
        - The lookup is now checked and returns an error.
      - `keys` is narrowed to `&FxIndexSet<ChunkGroupKey>` (also for
      `debug_str`).
        - `ChunkGroup::debug_str` resolves parents through `chunk_group_at`.
      - The output of a successful render is unchanged, so asset names don't
      change.
      - **`AvailableChunkGroups::assert_module_graph`.** This was a
      `debug_assert_eq!`. It now returns `Result`, and a graph mismatch is an
      error that names both graphs. The check is a cheap identity comparison,
      so it runs in all builds, not only debug builds.
      - `chunk_groups` and `with_chunk_group` now return `Result`, and callers
      propagate the error.
      - In `chunk_group_content_operation` the check runs once up front
      instead of in the per-module closures.
      
      #100928 / #100949 already cover the index panics in
      `get_chunk_groups_for_module` and `get_chunk_group`.
      
      ## Verification
      
      - `cargo test -p turbopack-core`. Adds
      `merged_chunk_group_with_unknown_parent_is_an_error`, which panicked at
      the same site as CI before this change.
      - `cargo clippy -p turbopack-core -p next-api -p next-napi-bindings
      --tests`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 8482d6ce-bad2-4131-98e3-4a391357a1c9 -->
      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>
      be19b72b
    • Tim Neutkens's avatar
      Revert "Revert "Fix App Router locale path matching with Pages i18n"" (#98726) · 7c5089fe
      Tim Neutkens authored
      Reverts vercel/next.js#98715. Re-apply the i18n fix.
      
      ---------
      Co-authored-by: 's avatarTim Neutkens <6324199+timneutkens@users.noreply.github.com>
      7c5089fe
    • Hendrik Liebau's avatar
      Fix prerendering of caught `'use cache'` errors (#100956) · a0e2b5dc
      Hendrik Liebau authored
      The error handler records errors thrown inside `'use cache'` functions
      in the work store's digest lookup. The page renderer uses that lookup to
      recover original errors for logging (#86500). Prerendering also uses it
      to detect render failures, so errors caught by the page can still fail
      the build or on-demand generation.
      
      This change collects errors reported by the page's RSC renderer
      separately and preserves the shared lookup for logging. The regression
      covers caught errors from `'use cache'` functions during build-time and
      on-demand prerendering and verifies that the fallback remains cacheable.
      
      This follows the reproduction, investigation, and proposed fix in
      #100841. We need to run deploy tests for this change. Those tests cannot
      run on fork PRs, so we are opening a branch PR in `vercel/next.js`.
      
      Fixes #100829.
      Closes #100841.
      Co-authored-by: 's avatarIkram-Maulana <hey@ikram.is-a.dev>
      a0e2b5dc
    • Hendrik Liebau's avatar
      [test] Cover cache handler validation during concurrent reads (#100908) · e8e020ca
      Hendrik Liebau authored
      The same-route test pauses a cache handler read after it checks implicit
      expiration. A second request starts after `revalidatePath()` invalidates
      that route. The assertions characterize the existing lookup-sharing bug
      for the wrapper rewrite in PR #100511.
      
      The prerender test pauses a finite implicit-tag expiration check and
      verifies that cache warming keeps long-lived cached content in the
      static shell. PR #100652 added coverage for cache reuse after
      revalidation and failed writes. These tests extend that coverage to
      concurrent handler validation.
      e8e020ca
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.34 · 64b6a09a
      next-js-bot[bot] authored
      64b6a09a
    • Tobias Koppers's avatar
      fix(turbopack): fix canary build after chunk_groups became a Vec (#100949) · 00161ce1
      Tobias Koppers authored
      ### What?
      
      Fixes the canary build. `turbopack-core` doesn't compile since #100928
      merged:
      
      ```
      error[E0599]: no method named `get_index` found for struct `Vec<ChunkGroup>` in the current scope
      ```
      
      ### Why?
      
      This is a semantic merge conflict:
      
      - #100935 changed `ChunkGroupInfo::chunk_groups` from an
      `FxIndexSet<ChunkGroup>` to a `Vec<ChunkGroup>`.
      - #100928's `ChunkGroupInfo::chunk_group_at` was tested on a base
      without that change. It still calls `get_index`, which exists only on
      `IndexSet`.
      
      ### How?
      
      Use `Vec::get`. It returns the same `Option<&ChunkGroup>`, so the error
      context and behavior stay the same. No other code has `IndexSet`-only
      calls on `chunk_groups`.
      
      Verified locally with `cargo fmt --check` and with `cargo check -p
      turbopack-core --all-targets` under `-D warnings`.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- 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>
      00161ce1
    • Niklas Mischkulnig's avatar
      Reland "perf(turbopack): canonicalize async loader availability" (#100947) · 801b7f1d
      Niklas Mischkulnig authored
      Reverts #100898
      Reapplies #100705
      801b7f1d
    • Tobias Koppers's avatar
      fix(turbopack): avoid panics from transient chunk group indices (#100928) · 84112add
      Tobias Koppers authored
      ### What?
      
      In `next dev` with Turbopack lazy dynamic imports
      (`experimental.turbopackLazyDynamicImports` and/or
      `turbopackLazyDynamicImportsSSR`), apps with nested `React.lazy(() =>
      import(...))` client components log Rust panics while lazy imports
      activate:
      
      ```
      thread 'tokio-rt-worker' panicked at turbopack/crates/turbopack-core/src/module_graph/chunk_group_info.rs:111:51:
      index out of bounds: the len is 31 but the index is 31
      ```
      
      The dev server recovers and pages render, but the output is noisy and
      the panics hide real errors. This PR turns that out-of-range lookup into
      a contextual, transient error and adds regression coverage. It doesn't
      touch #100705 or canonicalization (#100705 was reverted in #100898). The
      panic happens on canary without it.
      
      ### Why?
      
      `compute_chunk_group_info` creates the `module_chunk_groups` and
      `chunk_group_indices` child cells with `ResolvedVc::cell(...)` while it
      builds the result, and creates the outer `ChunkGroupInfo` cell, which
      holds `chunk_groups` inline, at the end. Each cell is published when it
      is written (`turbo-tasks-backend/src/backend/operation/update_cell.rs`).
      So while lazy activation recomputes the graph, an eventually consistent
      reader of `get_chunk_groups_for_module` (or `get_chunk_group`) can pair
      the **old** inline `chunk_groups` with a **new** child cell. If the new
      graph has more chunk groups, `self.chunk_groups[index]` is out of range.
      
      I confirmed this with temporary instrumentation that wasn't committed,
      on a fixture like the new test:
      - 34 `compute_chunk_group_info` executions. Each was internally
      consistent (max index = len − 1).
      - 1147 reads, of which 59 paired cells from different executions. 3 were
      out of range (the panics), and 56 had in-range indices.
      - For all 26 affected modules, the last read was consistent and newer
      than every torn read. The reader depends on both cells and is
      recomputed, so strongly consistent consumers end up with the correct
      result.
      
      ### How?
      
      - `ChunkGroupInfo::chunk_group_at` replaces direct indexing in
      `get_chunk_groups_for_module` and `get_chunk_group`.
      - An index from a child cell that the inline `chunk_groups` doesn't have
      becomes an `anyhow` error with context, never an empty or partial
      result.
        - The dependencies and keyed reads are the same as before.
      - **This is a guard, not a consistent snapshot.** Torn reads with
      in-range indices are still possible in the middle of a recomputation,
      and they are corrected by recomputation as before. Making them
      impossible needs coherent publication or snapshot identity across the
      cells, which is a separate design.
      
      **Tests**
      - `test/development/app-dir/lazy-dynamic-nested-imports`: nested
      `React.lazy` imports with `x` reached from `a`, `c` and `y`, with both
      lazy flags enabled.
        - Checks every level in the SSR HTML.
      - Hydrates every level in the browser with `retry()`, and asserts that
      no request returns ≥ 400 and that there are no transport errors. Browser
      cancellations (`net::ERR_ABORTED`) are ignored; they happen without this
      change too.
        - Asserts that the CLI output contains no `panicked` and no `⨯`.
      - Without the fix it fails on the panic assertion (39 panics). With the
      fix it passed 3 runs in a row.
      - A deterministic Rust test
      (`test_chunk_groups_for_module_with_mixed_generation_cells`) pairs a
      real graph's membership cell with a truncated inline group list. It
      panics before the fix and returns the error after it.
      
      **Verification** (on canary `a14cbc44`)
      - 12 dev sessions of a nested lazy fixture: 2 shapes × client lazy / SSR
      lazy / both × 2 sessions. All clean: 0 panics, 0 `⨯`, SSR and hydration
      OK. Before the fix almost every lazy session panicked.
      - `test/development/app-dir/lazy-dynamic-imports` (19/19) and
      `lazy-dynamic-chunk-list-collision` (1/1).
      - `cargo nextest -p turbopack-core -p next-core`: 289 passed. `-p
      turbopack-tests`: 458 passed, no snapshot changes. fmt, check and clippy
      pass with `-D warnings`.
      - Production output is unchanged: for the fixture's 25 client files,
      path and SHA-256 are identical before and after.
      
      **Not fixed here**
      - A build with extra logging `await`s still hit an SSR `ChunkLoadError`
      for a lazy proxy chunk in 1 of 3 sessions, with no panic. That is a
      separate issue that I'm tracking separately.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- 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>
      84112add
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.33 · 2a1f6afa
      next-js-bot[bot] authored
      2a1f6afa
    • Luke Sandberg's avatar
      Turbopack: store ChunkGroupInfo::chunk_groups as a Vec (#100935) · fac43733
      Luke Sandberg authored
      Order matters, use a vec
      
      Using IndexSet gives us 'set equality' semantics (but deterministic
      iteration order), this is broken for chunk groups and can cause queries
      that depend on ordering to fail. Since in a wam build if the order of
      items in a chunk group changes, then we will reuse the old order (the
      cell update is considered equivalent)
      
      
      I am looking at other places where this is a risk but this one
      definitely is and is straightforward to fix
      
      <!-- I am a human, why would i deceive you? -->
      
      ---------
      Co-authored-by: 's avatarClaude Opus 5.5 <noreply@anthropic.com>
      fac43733
    • Hendrik Liebau's avatar
      [test] Fix flaky file-system-cache-clock tests (#100946) · e1a69737
      Hendrik Liebau authored
      The tests added in PR #100357 can race background fetch-cache writes
      after the HTTP response completes.
      
      The tests now wait for the expected value and `lastModified` timestamp
      on disk before checking cache reuse, stopping the server, or inspecting
      the rewritten entry. The first request after tag revalidation must still
      return fresh data without retries.
      
      [Flakiness
      metrics](https://app.datadoghq.com/ci/ci-cd/explorer/executions?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.name%3A%22file-system-cache-clock%20with%20the%20default%20memory%20cache%20reads%20a%20fetch%20cache%20entry%20written%20without%20a%20stored%20timestamp%22%20%40test.type%3A%22turbopack%22%20%40test.status%3A%22fail%22&agg_m=count&agg_m_source=base&agg_t=count&ci_cd_explorer_tab=tests&fromUser=false&start=1792744453308&end=1793349253308&paused=false)
      e1a69737
    • Sebastian "Sebbie" Silbermann's avatar
      Stop patching error inspection if source maps are disabled (#93364) · d726535d
      Sebastian "Sebbie" Silbermann authored
      If source maps are disabled, we're most likely running in a prod server
      where sourcemapping happens lazily when logs are inspected.
      Ignore-listing generated frames would forever hide n_m frames.
      
      It also avoids doing a bunch of work that just won't have any effect.
      
      As a follow-up, I'll experiment with showing all frames during
      next-build if all original frames are ignore-listed since that's a
      one-shot process. For next-dev, we'll continue showing no frames if
      everything is ignore-listed since you have an attached a debugger with
      the browser to get a high-fidelity UI to see ignore-listed frames.
      Co-authored-by: 's avatarClaude Code <noreply@anthropic.com>
      d726535d
    • Hendrik Liebau's avatar
    • Andrew Clark's avatar
      Define the review agent's team as the owners in review/OWNERS (#100927) · fcd3fdeb
      Andrew Clark authored
      REVIEW.md told the review agent to approve only PRs "from human authors
      on the Next.js team". Neither half of that was something the agent could
      check. It had no list of who is on the team, and it has no way to
      confirm that the person behind a GitHub account is human. Taken
      literally, the second condition can never be met, so the agent
      intermittently withheld approval from PRs it would otherwise approve,
      citing that it couldn't prove the author was human.
      
      The team is now defined as the owners listed in review/OWNERS, which the
      agent can check directly and which scripts/review-context.mjs already
      treats as the team when picking default reviewers. Bots and outside
      contributors aren't on that list, so excluding them no longer needs a
      separate "human" condition.
      
      The rule also now says outright that a team member's account stands for
      that person. The agent shouldn't try to prove the author is human, and
      it shouldn't withhold approval because a PR was written with an AI
      agent, which is the same refusal in another form.
      fcd3fdeb
  2. 29 Oct, 2026 11 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