1. 28 Aug, 2026 1 commit
  2. 27 Aug, 2026 32 commits
    • Luke Sandberg's avatar
      Upgrade Turbopack to hashbrown 0.15 (#97808) · ee3a50cc
      Luke Sandberg authored
      ### What?
      
      Upgrade Turbopack's workspace dependencies to DashMap 7.0.0-rc2 and
      Hashbrown 0.15.4, removing Hashbrown 0.14 from the `turbo-tasks-backend`
      dependency graph.
      
      ### Why?
      
      `turbo-tasks-backend` previously compiled two Hashbrown versions because
      its custom DashMap helpers shared Hashbrown 0.14's private raw table
      types. Converging the backend graph on Hashbrown 0.15 removes that
      duplicate backend codegen path and slightly reduces the shipped native
      addon's size.
      
      A clean release A/B of the unstripped x86-64 `next-napi-bindings` cdylib
      measured:
      
      | Revision | `libnext_napi_bindings.so` |
      | --- | ---: |
      | canary base `80576037` | 147,824,920 bytes |
      | PR | 147,818,576 bytes |
      | **Delta** | **−6,344 bytes (−0.0043%)** |
      
      The final gain is small because unrelated SWC dependencies still pull
      DashMap 6 / Hashbrown 0.14 into the same addon; this change removes only
      backend-specific Hashbrown 0.14 codegen. Plus... nearly everything is
      monomorphized anyway
      
      ### How?
      
      DashMap 7 replaces its Hashbrown 0.14 raw table with Hashbrown 0.15's
      public `HashTable` API. The backend helpers now use that public API
      while retaining their existing shard locking and allocation behavior:
      
      - heterogeneous cache lookup and insertion still reuse a pre-located
      shard and precomputed hash;
      - the entry helper passes Hashbrown's native `hash_table::Entry` into a
      closure, preserving precise lock-release timing without a custom
      self-referential entry type or cloned hasher;
      - nonblocking removal still avoids lock-order deadlocks;
      - two-key mutation uses a release-mode disjointness assertion followed
      by `get_many_unchecked_mut` to avoid a redundant duplicate-pointer scan;
      - snapshot draining still transfers ownership of each shard table and
      releases task memory incrementally;
      - custom mutable guards remain non-`Send`.
      
      The migration also replaces several raw-pointer iteration and removal
      paths with safe `HashTable` operations. Existing raw-entry users in
      `auto-hash-map` and `turbopack-trace-server` explicitly enable Hashbrown
      0.15's compatibility feature.
      
      ### Performance
      
      Performance testing with the overhead.rs benchmark revealed no
      regression/progression
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 53ff0bed-46a9-4361-befa-a1791d585f27 -->
      
      ---------
      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>
      ee3a50cc
    • Aurora Scharff's avatar
      ci: skip framework tests for agent evals and skills (#97998) · 49d3043e
      Aurora Scharff authored
      Agent evals, skills, and the eval runner do not affect the framework
      runtime, but they currently make `Determine changes` schedule the full
      Rust, native, deployment, and framework test matrices.
      
      Classify changes confined to `evals/`, `skills/`, and `run-evals.js`
      with the existing lightweight documentation path. The always-on build
      and lint checks still run.
      
      Validated with Node syntax checking, Prettier, ESLint, and `git diff
      --check`.
      49d3043e
    • Will Binns-Smith's avatar
      Expand Turbopack dev cleanup (#97833) · 12bf495e
      Will Binns-Smith authored
      ## Summary
      
      Builds on #97591. Webpack currently removes most of `.next` on devserver
      startup. We can remove more as well.
      
      This keeps the age-based removal introduced in #97591 and expands it to
      `traces`, logs, etc. However, for any other directory that is not
      `cache` or `lock`, completely remove it on startup. This includes types,
      etc.
      
      Apply age-based deletion to Turbopack-owned output that can be restored
      from cache or recomputed, including route entries, chunks, assets,
      service workers, middleware, and instrumentation. Completely remove
      other dev output so logs, traces, generated types, diagnostics, and
      future framework-owned output cannot be left as mixed generations.
      
      Use exact-path exclusion sets in `recursiveDeleteSyncWithAsyncRetries`.
      The complete pass retains `cache`, `lock`, and Turbopack-owned paths;
      the age-based pass then sweeps those Turbopack paths. Both passes finish
      before project creation.
      
      ## Verification
      
      - `pnpm test-unit test/unit/recursive-delete.test.ts`
      - `pnpm --filter=next types`
      
      ---------
      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>
      12bf495e
    • Andrew Clark's avatar
      Add Cache Components option to create-next-app (#97695) · b882af08
      Andrew Clark authored
      When initializing a new project with create-next-app, the interactive
      prompt will now ask the user if they want to enable Cache Components.
      
      For now the option defaults to off. We'll flip the default back on once
      there's a flow that guides users to the right recommendation based on
      the kind of site they're building. The option can still be enabled
      interactively, or with the `--cache-components` flag.
      
      If the user chooses to enable Cache Components, the project will also be
      initialized with Partial Prefetching enabled. There's no separate prompt
      for Partial Prefetching; the only reason they are separate configs is
      because Cache Components shipped in 16.0 before Partial Prefetching
      existed.
      
      This is not a breaking change because it does not change any behavior in
      Next.js itself, only the create-next-app CLI. It has no impact on any
      existing Next.js projects.
      b882af08
    • Maya's avatar
      Mark deploy release test skill as internal (#97961) · 89ba4a32
      Maya authored
      ## Summary
      
      - mark the deploy-release-test repository skill as internal
      - prevent public skill discovery and telemetry publication for this
      repo-only workflow
      
      ## Testing
      
      - validated the SKILL.md frontmatter parses with metadata.internal set
      to true
      - git diff --check
      Co-authored-by: 's avatarAurora Scharff <66901228+aurorascharff@users.noreply.github.com>
      89ba4a32
    • Niklas Mischkulnig's avatar
      Turbopack: shorten CSS module class names (#97944) · 1f52cb42
      Niklas Mischkulnig authored
      The class names were unnecessarily long.
      
      Use the same as the lightningcss default:
      `[hash]_[local]` which is
      `<hash of the full file path>_<original class name or identifier>`
      
      Keep the previous longer mechanism to aid in debugging in dev
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      1f52cb42
    • Josh Story's avatar
      Prune incomplete parallel route matchers (#97108) · 6d6228c0
      Josh Story authored
      ## Summary
      
      This adds an experimental `strictRouteMatching` flag that leaves a
      matcher out when its finalized loader tree contains a synthesized
      default that will always call `notFound()` for a slot actually declared
      by the owning layout. Adding a `default.tsx` keeps the matcher, and
      structural router-state branches that are not real slots of that layout
      do not make it incomplete. The flag defaults to `false` so matcher
      pruning can roll out independently from the preceding loader-tree
      correction.
      
      The main goal is to make `children` and named slots behave the same way.
      If a URL cannot construct a complete route tree on its own, it should be
      treated as an unmatched URL instead of sometimes showing a slot 404 and
      sometimes producing a missing page or default error.
      
      ## Semantics
      
      For example:
      
      ```text
      app/split-matcher/
      ├── layout.tsx
      ├── foo/page.tsx
      ├── bar/page.tsx
      └── @slot/[...parts]/page.tsx
      ```
      
      With strict route matching disabled, Next.js emits matchers for
      `/split-matcher/foo`, `/split-matcher/bar`, and the broad
      `/split-matcher/[...parts]`. The broad matcher can match any URL, but
      its `children` branch has neither a matching page nor a default, so it
      can only construct a permanent 404 tree. With strict route matching
      enabled, that broad matcher is omitted while `/foo` and `/bar` remain
      because each combines a real `children` page with the named-slot
      catchall. Adding `app/split-matcher/default.tsx` deliberately makes the
      broad matcher complete and keeps it.
      
      The same rule applies without a catchall:
      
      ```text
      app/disagreeing-slots/
      ├── layout.tsx
      ├── @first/foo/page.tsx
      └── @second/bar/page.tsx
      ```
      
      `/foo` is incomplete because `@second` has no matching page or default,
      and `/bar` is incomplete for the corresponding reason in `@first`, so
      neither matcher is emitted. A later PR in this stack reports the
      now-unreachable page files as a project misconfiguration.
      
      A declared `children` route is treated like any named slot:
      
      ```text
      app/declared-children/
      ├── layout.tsx
      ├── page.tsx
      └── @panel/
          ├── default.tsx
          └── details/page.tsx
      ```
      
      `/declared-children` is complete because `children` uses `page.tsx` and
      `@panel` uses its default. `/declared-children/details` is incomplete
      because `@panel` matches its page while the declared `children` slot has
      no matching page or default at `/details`, so that matcher is pruned.
      
      A route composed entirely from declared named slots is also complete:
      
      ```text
      app/named-only/
      ├── layout.tsx
      ├── @left/[...slug]/page.tsx
      └── @right/[...slug]/page.tsx
      ```
      
      The preceding PR's default-on `explicitParallelRouteChildren` behavior
      means this loader tree contains only `left` and `right`. Strict matching
      keeps `/named-only/[...slug]` because both declared slots match; it does
      not invent `children` and then prune the route for failing to satisfy
      that nonexistent slot.
      
      We got here incrementally.
      [#47872](https://github.com/vercel/next.js/pull/47872) introduced the
      404 fallback for unmatched parallel slots,
      [#60186](https://github.com/vercel/next.js/pull/60186) added a
      development warning because this was confusing in practice and linked
      [#51805](https://github.com/vercel/next.js/issues/51805) and
      [#49569](https://github.com/vercel/next.js/issues/49569), and
      [#84702](https://github.com/vercel/next.js/pull/84702) later made a
      missing default a build error for named slots while leaving `children`
      on the old fallback for backwards compatibility. Strict matching takes
      the next step and treats a matcher that can only construct a permanent
      404 tree as unmatched.
      
      This changes soft navigations that only worked by preserving a
      previously active slot even though the URL could not be loaded directly,
      which is why matcher pruning remains behind its own experimental flag.
      The interception retention markers backed by `default-null`, including
      named host slots from the first PR in this stack, are complete route
      patches and are not pruned. This change however is well motivated
      because if you did client nav to a route that only matches a named slot
      and then hard refresh you will end up getting a 404. This is a sign our
      current semantics are actually broken.
      
      If you want to preserve the perma 404 behavior of the
      slot-without-default you can just add a default and make it call
      `notFound()` unconditionally.
      
      ## Verification
      
      - `pnpm build-all`
      - Focused `normalize-catchall-routes` unit coverage
      - Production and development e2e coverage on Turbopack and Webpack
      - The pruning e2e matrix with Cache Components enabled
      
      <!-- NEXT_JS_LLM -->
      6d6228c0
    • next-js-bot[bot]'s avatar
    • Aurora Scharff's avatar
      docs(skills): preserve prefetched UI during Partial Prefetching adoption (#97712) · 24ed66ab
      Aurora Scharff authored
      ## What
      
      - Documents how legacy `prefetch={true}` behavior changes with Partial
      Prefetching and how to choose the UI worth preserving.
      - Updates the adoption skill to capture a passing flag-off `instant()`
      baseline, use the same assertions to drive the migration, and retain
      them as regression coverage.
      - Adds a reusable production test rig, keeps additional per-link
      optimization separate from adoption, and surfaces `prefetch={false}`
      links that may no longer be needed.
      - Applies the shared test-rig fixes discovered during dogfooding to the
      Cache Components optimizer.
      
      ## Why
      
      Legacy `prefetch={true}` could include uncached dynamic content. With
      Partial Prefetching, it includes the shared App Shell and cached
      URL-specific content instead. A passing build or clean insight sweep
      does not prove that the intended prefetched UI survived the migration,
      so the skill now records that contract before adoption and verifies it
      unchanged afterward. The guide presents the same test workflow as an
      optional programmatic check for manual adopters.
      
      ## Testing
      
      - Prettier, Alex, and skill frontmatter validation
      - Dogfooded on v0 in https://github.com/vercel/v0/pull/28842
      - Partial Prefetching adoption eval: 6/6 in
      https://github.com/vercel/next.js/pull/97759
      24ed66ab
    • Josh Story's avatar
      Omit undeclared children slots from app routes (#97184) · 05ed7c1b
      Josh Story authored
      ## Summary
      
      Parallel route layouts can be composed entirely from named slots, but
      loader tree construction currently synthesizes a `children` fallback
      whenever any named slot exists. This makes `children` semantically
      required even when no page, default, or ordinary route branch declares
      it.
      
      This adds `experimental.explicitParallelRouteChildren` and enables it by
      default. When enabled, `children` is included in a layout slot set only
      when the filesystem declares an ordinary route that can render at that
      level. A layout by itself is only structure and does not declare a route
      target. Ordinary descendants are traced until they reach a page or
      default, including through deeper named slots, before they cause
      `children` to be included. Setting the flag to `false` temporarily
      restores the legacy implicit `children` fallback.
      
      This flag only controls whether `children` exists in the loader tree. It
      does not prune incomplete matchers; that is the separate
      `experimental.strictRouteMatching` behavior in the next PR.
      
      Named slots keep their existing default and soft navigation semantics.
      The preceding PR retains the slots owned by an interception host without
      treating `children` specially, so an undeclared child is no longer
      needed for that behavior. A real `children` branch still uses the
      retention marker when it is one of the host layout slots.
      
      ## Semantics
      
      For example, this layout declares only named slots:
      
      ```text
      app/dashboard/layout.tsx
      app/dashboard/@left/page.tsx
      app/dashboard/@right/page.tsx
      ```
      
      With `explicitParallelRouteChildren` disabled, Next.js adds a synthetic
      `children` branch whose built-in default calls `notFound()`, even though
      the layout never declared or rendered it. With the default behavior
      enabled, the loader tree contains only `left` and `right`, so
      `/dashboard` is matched from the route targets that actually exist.
      
      This is different from an ordinary branch whose route targets are deeper
      in the tree:
      
      ```text
      app/nested/layout.tsx
      app/nested/@sidebar/[...slug]/page.tsx
      app/nested/content/layout.tsx
      app/nested/content/@left/[...slug]/page.tsx
      app/nested/content/@right/[...slug]/page.tsx
      ```
      
      Here `content` really is the `children` branch of `nested`. The scan
      follows `content` through its layout and deeper named slots, so
      `children` remains required. `/nested/content/anything` can construct
      every declared slot, while `/nested/incomplete` only matches `sidebar`
      and is still incomplete. The distinction is whether the ordinary
      descendant eventually reaches a page or default, not whether a layout
      happens to exist along the way.
      
      The focused children detection coverage proves that a layout-only
      descendant does not synthesize `children`, while an ordinary branch
      whose route targets live inside deeper named slots still does. The
      limitation coverage also proves that named-only trees render pages, CSS,
      metadata, and regular error boundaries. It intentionally asserts the
      current broken behavior for HTTP access fallbacks and metadata or
      viewport failures so those expectations can be flipped when renderer
      ownership no longer depends on `children`.
      
      ## Verification
      
      - `pnpm build-all`
      - Turbopack and webpack development and production coverage for
      `explicit-parallel-route-children-detection`
      - Turbopack and webpack production coverage for
      `interception-dynamic-segment`, `parallel-routes-layouts`, and
      `explicit-parallel-route-children-legacy`
      - The same existing production coverage with Cache Components enabled
      - Turbopack and webpack production coverage for the documented
      named-only limitations
      
      <!-- NEXT_JS_LLM -->
      05ed7c1b
    • Tobias Koppers's avatar
      Turbopack: widen the chunk ident hash from 7 to 13 base38 chars (#97945) · cbe4687b
      Tobias Koppers authored
      Closes #97766.
      
      ### What?
      
      Widen the chunk ident hash in `turbopack-core/src/ident.rs` from 7 to 13
      base38 characters.
      
      ### Why?
      
      7 base38 characters is ≈36 bits nominally, and closer to ~32 in practice
      because the leading character is bounded — an effective space of roughly
      6×10⁹. Any population of chunks that shares a readable name prefix and
      is distinguished **only** by that hash is therefore a birthday problem:
      at n names the collision probability is ≈ n²/2M, so around 10⁵ such
      chunks collide with probability of order 1 and the build aborts with:
      
      ```
      Two or more assets with different content were emitted to the same output path
      ```
      
      This is not hypothetical at real app sizes:
      
      - #97765 — deterministic reproduction (this PR fixes it): 120,000 chunks
      sharing one prefix, fails byte-identically on every run, same collided
      path and same rejected content hashes across consecutive builds.
      - #96976 — production App Router app, ~69,000 emitted server chunks, ≈9%
      failure probability per build measured, growing quadratically with chunk
      count.
      
      The ergonomics are the painful part: the colliding pair is chosen by the
      hash, not by any structural property. The failure lands on whichever
      branch last touched the module graph and looks like that branch's fault;
      bisecting finds a commit but never a responsible file; and moving a
      module only reshuffles which pair collides. We verified that a module
      renamed *inside* a colliding chunk does not change the chunk's name at
      all — same two chunks, same 7-character name, renamed file listed
      inside.
      
      ### How?
      
      ```diff
                   let hash = encode_base38(hasher.finish());
      -            // 7 base38 chars ≈ 36 bits of collision resistance
      -            let truncated_hash = &hash[..7];
      -            write!(name, "_{truncated_hash}")?;
      +            // Use the complete fixed-width base38 encoding of the 64-bit hash.
      +            //
      +            // This suffix is what distinguishes idents that share a readable
      +            // name prefix, so truncating it makes distinct output paths collide
      +            // for large module graphs, failing the build with "Two or more
      +            // assets with different content were emitted to the same output
      +            // path". Keeping all 64 bits removes that failure mode, at the cost
      +            // of a slightly longer file name.
      +            write!(name, "_{hash}")?;
      ```
      
      The complete 13-character base38 encoding preserves all 64 bits of the
      identity hash. Cost: 6 extra characters per emitted chunk filename.
      
      ### Notes for reviewers
      
      - Output filenames change wholesale on upgrade, as with any naming
      change; nothing reads these names across versions.
      - Snapshot tests that pin emitted chunk names have been regenerated.
      - If you would rather solve this by hashing more distinguishing input
      rather than widening the truncation, I am glad to rework it; the length
      is the smallest change that removes the failure mode.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet daf6a1b0-ebda-4eed-a89f-03e5ec7dc357 -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarjonnyuniverse <jon@fractionalventure.partners>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
      cbe4687b
    • David Gray's avatar
      Fix request-context retention in the default use cache handler (#97941) · c5b960e2
      David Gray authored
      Fixes #97934.
      
      The default use cache handler uses live ReadableStream objects. Those
      streams retain references to the request’s async context and closed HTTP
      response, causing memory to grow with cached entries and potentially
      produce OOMs.
      
      The fix converts each stream into a plain Buffer before caching it.
      Every cache hit then gets a fresh temporary stream created from those
      bytes. The content remains cached, but completed requests can now be
      garbage-collected.
      
      ---
      
      Basically - the LRU cache stores live ReadableStream objects, which keep
      completed request contexts and closed responses in memory until that
      cache is evicted.
      c5b960e2
    • Rich Haines's avatar
      docs: improve discovery summaries (#97982) · e80a85bc
      Rich Haines authored
      This PR improves the meta descriptions on certain pages.
      
      <!-- Thanks for opening a PR! Your contribution is much appreciated.
      To make sure your PR is handled as smoothly as possible we request that
      you follow the checklist sections below.
      Choose the right checklist for the change(s) that you're making:
      
      ## For Contributors
      
      We encourage you to use AI to assist you in researching, creating, and
      reviewing changes. However, you must review and deeply understand the
      contributions you are making. For this reason, **pull request
      descriptions from external contributors must be written by a human**.
      
      ### Improving Documentation
      
      - Run `pnpm prettier-fix` to fix formatting issues before opening the
      PR.
      - Read the Docs Contribution Guide to ensure your contribution follows
      the docs guidelines:
      https://nextjs.org/docs/community/contribution-guide
      
      ### Fixing a bug
      
      - Related issues linked using `fixes #number`
      - Tests added. See:
      https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Adding a feature
      
      - Implements an existing feature request or RFC. Make sure the feature
      request has been accepted for implementation before opening a PR. (A
      discussion must be opened, see
      https://github.com/vercel/next.js/discussions/new?category=ideas)
      - Related issues/discussions are linked using `fixes #number`
      - e2e tests added
      (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
      - Documentation added
      - Telemetry added. In case of a feature if it's used or not.
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Signed commits
      
      - This repository requires verified commit signatures on protected
      branches.
      - If this pull request is blocked for unsigned commits, re-sign the
      commits and force-push the branch.
      - A `Signed-off-by` line in the commit message is not enough.
      
      ## For Maintainers
      
      - Minimal description (aim for explaining to someone not on the team to
      understand the PR)
      - When linking to a Slack thread, you might want to share details of the
      conclusion
      - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
      - Add review comments if necessary to explain to the reviewer the logic
      behind a change
      
      ### What?
      
      ### Why?
      
      ### How?
      
      Closes NEXT-
      Fixes #
      
      -->
      e80a85bc
    • Steven's avatar
    • Josh Story's avatar
      Retain interception route host slots (#97242) · cce7bf2f
      Josh Story authored
      ## Summary
      
      Interception routes represent a partial update to the layout that hosts
      them. Today we model this for `children` by synthesizing a `__DEFAULT__`
      route backed by `default-null`, but named siblings still use normal
      default matching even though they should retain their active state too.
      
      This makes retention relative to the interception host instead of the
      `children` key. Every non-intercepting sibling gets the existing
      `__DEFAULT__` marker backed by `default-null`, while slots inside the
      newly selected interception subtree continue to use normal matching and
      real defaults.
      
      The coverage uses a named-only host to verify that named siblings retain
      client state without evaluating a user default, that a sibling without a
      default also retains, and that a hard refresh still loads the canonical
      route.
      
      ## Example
      
      Consider this route tree:
      
      ```text
      app/
      ├── named-host/
      │   ├── layout.tsx                  # renders canonical, content, secondary, and modal
      │   ├── @canonical/
      │   │   └── page.tsx
      │   ├── @content/
      │   │   ├── page.tsx                # renders a stateful counter
      │   │   └── default.tsx             # throws if evaluated
      │   ├── @secondary/
      │   │   └── page.tsx                # has no default.tsx
      │   └── @modal/
      │       ├── default.tsx
      │       └── (..)named-target/
      │           └── page.tsx            # intercepted target
      └── named-target/
          └── page.tsx                    # canonical route
      ```
      
      Before this change, a soft navigation from `/named-host` to
      `/named-target` could replace `@content` with its throwing default and
      treat `@secondary` as missing because only `children` had retain
      semantics. After this change, only `@modal` switches to the intercepted
      page; `@content` and `@secondary` keep their existing UI and the counter
      keeps its state. A hard refresh still renders the canonical
      `/named-target` route instead of the interception host.
      
      ## Verification
      
      - Turbopack and webpack production coverage in
      `interception-dynamic-segment`
      - The same production coverage with Cache Components enabled
      
      <!-- NEXT_JS_LLM -->
      cce7bf2f
    • Janka Uryga's avatar
    • Tobias Koppers's avatar
      [test] Drain build output before start (#97947) · d42ea118
      Tobias Koppers authored
      ### What?
      
      Make the production test harness wait for a build process's piped stdio
      to close before `NextStartInstance.start()` continues to launch the
      server or reports a build failure.
      
      ### Why?
      
      A child process's `exit` event can fire before trailing stdout and
      stderr have been delivered to the parent. This can make start-mode tests
      intermittently miss diagnostics emitted near the end of a production
      build, even though the build itself reported them correctly.
      
      The standalone `build()` helper already uses the later `close` lifecycle
      event to avoid this race. Applying the same rule to the build phase
      inside `start()` removes the equivalent latent output-drain hazard and
      makes child-process handling consistent across the harness.
      
      ### How?
      
      Resolve the build phase on the child process's `close` event. Unlike
      `exit`, `close` is emitted after piped stdio closes, so all trailing
      build output has reached the harness before it starts the server or
      rejects the build. Exit-code and signal handling remain unchanged.
      
      ### Verification
      
      - `pnpm types`
      - `pnpm test-start-webpack
      test/production/production-build-dir/production-build-dir.test.ts`
      - `pnpm test-start-webpack
      test/production/app-dir/sync-io-blocks-root/sync-io-blocks-root.test.ts`
      - Repeated webpack stress campaign for the sync-IO suite: 5/5 runs,
      including 20/20 `--debug-prerender` route cases
      - Prettier and ESLint on `test/lib/next-modes/next-start.ts`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 821362ed-9f96-4e53-b56e-49bf00e878b9 -->
      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>
      d42ea118
    • Niklas Mischkulnig's avatar
      Expose durableUseCacheEntries config in workStore (#97926) · 3d85af96
      Niklas Mischkulnig authored
      https://github.com/vercel/next.js/pull/95233 needs this to decide
      whether to perform the manifest lookup.
      3d85af96
    • Tim Neutkens's avatar
      Pages Router: Deprecate React 18 support (#97689) · 89d017ea
      Tim Neutkens authored
      ## Summary
      
      - warn during `next dev` and `next build` when React 18 is installed,
      while keeping `next start` quiet
      - explain that React 18 remains supported in Next.js 16 but will be
      removed in Next.js 17
      - update the React version guidance with React 19 and TypeScript type
      upgrade commands
      
      ## Verification
      
      - `NEXT_TEST_PREFER_OFFLINE=1 pnpm test-dev-turbo
      test/e2e/react-current-version/react-current-version.test.ts`
      - `NEXT_TEST_REACT_VERSION=18.3.1 NEXT_TEST_PREFER_OFFLINE=1 pnpm
      test-dev-turbo
      test/e2e/react-current-version/react-current-version.test.ts`
      - targeted production build/start coverage passed with React 18 and
      React 19
      - Not passing: `pnpm --filter=next types` (existing unrelated errors in
      `httpget.ts`, `image-optimizer.ts`, `proxy-request.ts`, telemetry
      typings, and compiled declarations)
      - Not passing: `pnpm lint` (existing unused Turbo Tasks check)
      
      <!-- NEXT_JS_LLM -->
      89d017ea
    • Niklas Mischkulnig's avatar
      Turbopack: call loadActionManifest for app-route (#97921) · 286fcc34
      Niklas Mischkulnig authored
      For #95233, I need to read server-reference-manifest.json even for App
      Routes, which previously didn't emit server action manifest entries at
      all (because thus far, it was unnecessary).
      286fcc34
    • Niklas Mischkulnig's avatar
      [test] Unpin Vercel CLI version (#97974) · 529d290b
      Niklas Mischkulnig authored
      Reverts #97960
      vercel@59.7.0 should fix this again
      529d290b
    • Niklas Mischkulnig's avatar
      Turbopack: don't replace single-arg calls with argument in analyzer (#95277) · ef6e23fa
      Niklas Mischkulnig authored
      This was a hack added a long time ago. And it can lead to correctness
      issues
      ef6e23fa
    • Niklas Mischkulnig's avatar
      Turbopack: allow compiling turbopack-node without a pool backend (#97943) · 4160afe2
      Niklas Mischkulnig authored
      It failed to compile thus far if you didn't set any features.
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      4160afe2
    • Niklas Mischkulnig's avatar
      Support immutable static assets with `output: 'export'` (#97711) · 80f846c7
      Niklas Mischkulnig authored
      There was no real reason why this wasn't done thus far.
      `output: 'export'` already uses the adapter anyway.
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      80f846c7
    • Niklas Mischkulnig's avatar
      Fix build error when aliasing `typescript` to `@typescript/typescript6` (#97942) · d75bf1b8
      Niklas Mischkulnig authored
      This was previously broken, because the binary isn't called `tsc` but
      `tsc6`:
      ```json
      "dependencies": {
      	"typescript": "npm:@typescript/typescript6@6.0.1"
      }
      ```
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      d75bf1b8
    • Niklas Mischkulnig's avatar
      ci: remove pull_request_stats workflow (#97792) · d6e57416
      Niklas Mischkulnig authored
      This was quite useless (very flaky) and furthermore also slow
      d6e57416
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.9 · d4b7cc1f
      next-js-bot[bot] authored
      d4b7cc1f
    • jgruica's avatar
      fix: don't drop client references when the concatenated module id is 0 (#97936) · 97c6aedf
      jgruica authored
      ### What?
      `getModuleId()` returns `string | number | null`, and `0` is a valid id.
      The`ConcatenatedModule` fallback guards it with a truthiness check, so
      when the concatenated module gets id `0` the client entry is left out of
      the client reference manifest.
      
      ### Why?
      The
      [code](https://github.com/vercel/next.js/blob/d09816fdaf2fef7a23751de75a9dde6bb7c2403b/packages/next/src/build/webpack/plugins/flight-manifest-plugin.ts#L516)
      right above it already checks `modId !== null`. The two checks sit a few
      lines apart and disagree about whether `0` is a valid id, which looks
      like an oversight. When it happens the build fails with `Could not find
      the module ... in the React Client Manifest`, which doesn't point at the
      cause.
      
      Repro: https://github.com/jgruica/next-concat-modid-zero (needs
      `--webpack` plus `concatenateModules: true`, so it's rare in practice)
      
      ### How?
      One line in `flight-manifest-plugin.ts`: `if (concatenatedModId)`
      becomes `if (concatenatedModId !== null)`. `null` is still skipped, so
      nothing elsechanges.
      Co-authored-by: 's avatarMarcos Hernanz <96699542+marcoshernanz@users.noreply.github.com>
      97c6aedf
    • Jiwon Choi's avatar
      Replace resumed render bailout error with ReactDOM.browser behind a flag (#96844) · a65ccea5
      Jiwon Choi authored
      Stacked on #96843.
      
      This PR replaces the bailout error used to abort resumed renders with
      `ReactDOM.browser()` behind the experimental flag.
      
      ### How?
      
      Pass the flag to the App Router runtime, use `ReactDOM.browser()` as the
      abort reason when enabled, and preserve existing behavior otherwise.
      
      <!-- NEXT_JS_LLM -->
      a65ccea5
    • Jiwon Choi's avatar
      Replace useSearchParams bailout error with ReactDOM.browser behind a flag (#96843) · c11c48e4
      Jiwon Choi authored
      Stacked on #96826.
      
      This PR replaces the bailout error used by `useSearchParams` with
      `ReactDOM.browser()` behind the experimental flag.
      
      ### How?
      
      Move the bailout behind a browser-safe module boundary, use
      `ReactDOM.browser()` when enabled, and preserve existing behavior
      otherwise.
      
      <!-- NEXT_JS_LLM -->
      c11c48e4
    • Jiwon Choi's avatar
      Replace CSRBailout error with `ReactDOM.browser` behind a flag (#96826) · 23985382
      Jiwon Choi authored
      CSRBailout error is the use case for `ReactDOM.browser()`. Replace
      behind an experimental flag.
      This PR replaces the bailout error used in next/dynamic ssr: false.
      23985382
    • Muhammad Zeeshan's avatar
      fix(next/image): reject non-2xx internal image responses (#97957) · fad31750
      Muhammad Zeeshan authored
      - Fixes https://github.com/vercel/next.js/issues/82357
      - Closes https://github.com/vercel/next.js/pull/96985
      
      ### What?
      
      `fetchInternalImage()` only rejects the internal response when
      `statusCode` is falsy, and `MockedResponse` defaults it to `200`, so
      nothing really gets rejected there. A `307` coming from a `redirects()`
      entry in `next.config`, or a `404` for a path that isn't there, both
      count as a successful image fetch.
      
      That body then reaches `detectContentType()`, which returns `null`, and
      all you get is:
      
      ```
      The requested resource isn't a valid image for /path/to/image.png received null
      ```
      
      Nothing in that line points back at the response that actually came in,
      so a redirect looks exactly like a corrupt image.
      
      ### Why?
      
      `fetchExternalImage()` right above already covers this with `if
      (!res.ok)` and logs `res.status`. The internal path is the only fetch in
      the file without that check, so the same failure gets reported at the
      fetch for remote images, and three steps later as "not a valid image"
      for local ones.
      
      ### How?
      
      The guard now rejects anything outside the 2xx range, which is what
      `res.ok` means, and the log line carries the status next to the href.
      The thrown `ImageError` message stays generic, same as the external
      path, so nothing new shows up in the HTTP response body.
      
      Because that throw passes `mocked.res.statusCode` into `ImageError`, a
      non-2xx internal response now reports its own status instead of always
      landing on `400`. `ImageError` still maps anything under 400 to `500`,
      so a redirect answers `500` and a `404` stays `404`. That is what
      `fetchExternalImage()` has always done, and it lines the two up: a
      missing local image now returns `404` just like a missing remote one.
      
      Three assertions in `test/e2e/image-optimizer/util.ts` shift because of
      that:
      
      - `should not forward cookie header`: `/api/conditional-cookie` answers
      `401` when the cookie is missing, so `400` becomes `401`
      - `should error if the image file does not exist`: `/does_not_exist.jpg`
      returns `404` now, with the internal response message
      - `should error if the resource isn't a valid image`: this one requested
      `/test.txt`, but the fixture in `public/` is `text.txt`, so it was
      quietly exercising a missing file instead of a non-image file. Pointed
      at the file that exists, it keeps its original `400` and finally tests
      what its name says
      
      Two unit tests cover the new guard, one `307` and one `404`. Every other
      test in that file sets `statusCode = 200`, so they are untouched.
      
      #96985 is open against the same report with a different angle: it
      threads the status through `ImageUpstream` so the existing "isn't a
      valid image" log can print it. This one stops the request at the fetch,
      so the redirect never reaches the optimizer at all. Whichever one fits
      better, feel free to close mine.
      
      ### Verification
      
      - `jest test/unit/image-optimizer/`: 139/139, and the two new tests fail
      against a build without the guard
      - `pnpm test-dev
      test/e2e/image-optimizer/content-disposition-type.test.ts`: 97/97
      - `pnpm test-start
      test/e2e/image-optimizer/content-disposition-type.test.ts`: 97/97
      - `prettier --check` clean on the three changed files
      
      <!-- NEXT_JS_LLM -->
      Co-authored-by: 's avatarSteven <steven@ceriously.com>
      fad31750
  3. 26 Aug, 2026 7 commits
    • Sebastian "Sebbie" Silbermann's avatar
      [test] Pin Vercel CLI to Node 20.9 compatible version (#97960) · 49f791cc
      Sebastian "Sebbie" Silbermann authored
      - latest resolved to vercel@59.6.2.
      - It loads `@vercel/node@8.1.0` -> `@vercel/static-config@3.4.2`.
      - `@vercel/static-config` is CommonJS and calls `require("oxc-parser")`.
      - `oxc-parser@0.121.0` is ESM-only and requires Node `^20.19.0 ||
      >=22.12.0`.
      - CI is running Node 20.9.0, which cannot synchronously
      49f791cc
    • Sebastian "Sebbie" Silbermann's avatar
      Re-enable AVIF image optimization (#97931) · 1a7ccf48
      Sebastian "Sebbie" Silbermann authored
      Reverts #97875 and bumps `sharp` from `^0.35.3` to `^0.35.4`,
      re-enabling AVIF image optimization.
      
      
      `minimumReleaseAge` interplay (verified with pnpm 10.33.0 and 11.22.0 in
      a standalone repo with a `file:` dependency declaring sharp as an
      optional dependency):
      
      - sharp 0.35.4 was published on 2026-08-26 and is younger than this
      repo's 48h `minimumReleaseAge`.
      - pnpm aborts the whole install with
      `ERR_PNPM_NO_MATURE_MATCHING_VERSION` when no in-range release satisfies
      the age gate. This applies to `optionalDependencies` (no warn-and-skip)
      and through `file:` dependencies alike.
      - The gate also covers the `@img/sharp-*` binary packages sharp 0.35.4
      depends on, so excluding only `sharp@0.35.4` is not enough.
      - `pnpm-workspace.yaml` therefore exempts `sharp@0.35.4` and
      `@img/sharp-*` (pnpm does not allow version qualifiers on name patterns
      in this setting). Both entries can be dropped once 0.35.4 is older than
      48 hours.
      - Downstream users who configure their own `minimumReleaseAge` will hit
      the same hard install failure when installing a release with this bump
      until 0.35.4 ages out, unless they add the same excludes. Keeping
      `^0.35.3` is not a safer alternative: age-gated installs would then
      silently resolve the vulnerable 0.35.3.
      
      Part of https://linear.app/vercel/issue/VOC-34654/
      
      ---------
      Co-authored-by: 's avatarSteven <steven@ceriously.com>
      1a7ccf48
    • Lazizbek Ergashev's avatar
      Don't report a client-aborted RSC stream as a render error (#96715) · 0c7f81e6
      Lazizbek Ergashev authored
      When a client disconnects mid-stream, `pipeNodeReadableToNodeResponse`
      destroys the readable React is piping into. React sees its destination
      close before the render ended and aborts with a generic `Error("The
      destination stream closed early.")`, which `onError` has no way to
      distinguish from a real render error, so it ends up in `onRequestError`
      as a server render error.
      
      The Web streams path doesn't have this problem: cancelling the readable
      passes the `ResponseAborted` reason straight through to React. This does
      the same for the Node path by aborting the pipeable with that reason as
      soon as the passthrough is destroyed early, before React's own close
      handler runs. Genuine render errors still go through untouched.
      
      Fixes #96704
      
      ---------
      Co-authored-by: 's avatarJude Gao <jude.gao@vercel.com>
      0c7f81e6
    • Janka Uryga's avatar
      [PPF] Only track runtime accesses when the promise is used (#97165) · d352f174
      Janka Uryga authored
      Improves how we track accesses of runtime data in static prerenders
      (which affects whether a page will use static or runtime shells).
      Now, Instead of tracking it when the hanging promise is created, we'll
      track it when `then/catch/finally` is called on the promise (which we
      use as a signal for being used).
      
      The promise tracking required some novel work, because:
      
      - Using a proxy seems to cause `Promise.then` to show up in call stacks
      (we've had issues with proxies throwing off React's IO tracking before,
      i believe this is a similar problem)
      - patching `then/catch/finally` on the promise directly doesn't work,
      because `then` doesn't get called for native `await`
      
      The only way of doing this that i've found is a custom `Promise`
      subclass that tracks the access in its `then` implementation. This is
      what `TrackedPromise` does.
      
      To improve the debuggability, i've added some debug logs enabled by
      `NEXT_PRIVATE_DEBUG_RUNTIME_DATA=1` to detect when a page is deopted to
      runtime and what expression caused it.
      
      ---
      
      This fixes a false deopt caused by `createServerPathnameForMetadata` -
      when called on a route with fallback params, it would always track a
      fallback params access even if no icons/og images that actually use it
      exist. This meant that we'd never statically optimize any routes that
      had fallback params. After this PR, we only track a runtime data access
      if a metadata route that uses that params actually exists, in which case
      the `pathname` promise gets awaited.
      (as a future optimization, we should do the equivalent of vary params
      tracking on metadata routes to know if the params are used at all. also,
      the logic in `pathname.ts` is generally in need of cleanup)
      d352f174
    • Tobias Koppers's avatar
      Fix Turbopack re-export cycle deadlock (#97933) · 0304c4ff
      Tobias Koppers authored
      ### What?
      
      Prevents Turbopack from deadlocking while resolving re-exports through
      an import cycle by making ECMAScript side-effect classification
      independent of full module analysis.
      
      The supplied async regression is added to the normal execution suite,
      along with a synchronous variant demonstrating that the facade/locals
      re-export cycle itself is sufficient to trigger the issue.
      
      ### Why?
      
      Cross-module constant analysis resolves eligible imported bindings while
      the importing module's analysis is still running. Re-export following
      asks synthesized locals modules for side effects, which delegate to
      their original modules. The previous fallback obtained side effects from
      the full `AnalyzeEcmascriptModuleResult`, so an import cycle could
      re-enter an already-running analysis task and close a Turbo Tasks await
      cycle.
      
      The actual static side-effect classifier only needs the parsed SWC
      program, comments, unresolved mark, directives, and module options.
      Reference analysis is not required.
      
      This also unblocks the export-mangling work in #97770.
      
      ### How?
      
      Side-effect classification now runs in a dedicated parse-only Turbo
      Task. Package/config declarations retain precedence; when none exists,
      the task uses `failsafe_parse()` and the existing AST classifier without
      resolving references or awaiting `analyze()`.
      
      `AnalyzeEcmascriptModuleResult.side_effects` and its builder state are
      removed because the module-side-effects fallback was its only consumer.
      This also eliminates unused duplicate classification during module-part
      analysis.
      
      `follow_reexports` and module-fragments side-effect handling remain
      unchanged from canary.
      
      ### Verification
      
      - `cargo test -p turbopack-tests --test execution` — 265 passed, 0
      failed
      - `cargo test -p turbopack-ecmascript` — 525 passed, 0 failed
      - Focused re-export-cycle and side-effect-retention tests in both
      optimization modes
      - `cargo fmt -- --check`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 4bbd5119-2442-4053-a856-f9d596924113 -->
      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>
      0304c4ff
    • Andrew Clark's avatar
      Port React's @gate test directive to the e2e harness (#96228) · 94327e8a
      Andrew Clark authored
      The test suite has accumulated a bunch of patterns for disabling tests
      that are known to fail under some configuration: `it.skip`, `if
      (isNextDev) { test('skipped in dev mode', () => {}); return }`, whole
      describes toggled off by checking `process.env.__NEXT_CACHE_COMPONENTS`.
      These all have the same flaw: nothing tells you when the thing you
      skipped starts working. The test stays disabled forever, and the
      workaround it was guarding rots along with it.
      
      React solves this with the `@gate` pragma, and this PR ports it to the
      Next.js e2e harness:
      
      ```ts
      // Blocked on the optimization that marks a route as fully static when
      // no dynamic params are referenced in Server Components.
      // @gate !cacheComponents
      it('navigates to a page with a lazily-generated static param', async () => {
        // body unchanged
      })
      ```
      
      The test still runs. If the condition is false and the test fails, the
      failure is absorbed and the suite stays green. If it _passes_, the suite
      fails: the gate is stale, delete it. So instead of a skip that hides a
      fixed bug indefinitely, you get a CI failure the day the fix lands.
      
      When the condition is static, the inversion is Jest's own `test.failing`
      under the hood. A lazy condition isn't known until the fixture's
      resolved config is read inside the body, so those tests invert at
      runtime instead.
      
      `// @force-gate <condition>` skips for real — for tests that can't even
      be attempted (prefetching is disabled in dev, deploy has no local build
      output, the fixture won't build under the condition), and for tests of a
      new API, where the disabled state can only throw and running it proves
      nothing:
      
      ```ts
      // Prefetching is disabled in dev, so this suite has nothing to test.
      // @force-gate prefetching
      describe('segment cache prefetch scheduling', () => {
        // ...
      })
      ```
      
      There's no staleness check in that case, so this is a judgment call:
      prefer `@gate` when the off state fails for a meaningful reason — the
      flag changes behavior that already exists — and `@force-gate` when the
      body can only throw because the API doesn't exist. A static condition
      (mode, bundler) resolves at collection time into a normal Jest skip. A
      lazy condition resolves at runtime, and when a lazy force-gate on a
      describe is false, we skip the fixture build entirely — that's what
      makes it usable for suites whose fixtures are build-incompatible with
      the condition. (One caveat: Jest has no way to skip a test that's
      already running, so these report as passing with a warning in the log,
      not as skipped.)
      
      Conditions live in a hand-written registry. I considered deriving the
      lazy ones from the config schema automatically, but a gate is a claim
      about which dimension of the test matrix explains a failure, and I'd
      rather each of those claims be spelled out with a description.
      Referencing an undeclared name fails the suite at collection time, so a
      typo can't silently disable a gate.
      
      The important design decision for lazy conditions is that they read the
      fixture's _resolved_ config, never `process.env`. The env var isn't the
      truth: `__NEXT_CACHE_COMPONENTS=true` only applies when the fixture
      doesn't set `cacheComponents` itself, and config resolution implies
      flags the fixture never mentions (`cacheComponents: true` alone turns on
      `experimental.ppr`). Resolution happens in a child process, because
      in-process `loadConfig` would leak the fixture's `.env` files into the
      Jest worker. Suites with no lazy gate never pay for any of this.
      
      The condition expression is parsed using a small grammar (also ported
      from the React repo). An expression that doesn't parse fails the suite:
      
      ```ts
      // @gate mode === 'start' && !cacheComponents
      // @gate !(turbopack || rspack)
      ```
      
      There's also a runtime version, mirroring React's `gate(flags =>
      flags.enableFoo)`, for tests that run under both states but assert
      differently (and for `it.each`, where the pragma can't attach):
      
      ```ts
      import { gate } from 'next-test-utils'
      
      it('renders the fallback', async () => {
        if (await gate((conditions) => conditions.cacheComponents)) {
          // PPR: the fallback is part of the static shell
        } else {
          // fully dynamic: the fallback streams in
        }
      })
      ```
      
      It also accepts the pragma expression language as a string: `await
      gate('cacheComponents && !dev')`.
      
      Docs are in `test/lib/gate/README.md`; `test/unit/gate/` covers the
      transform, the expression language, and the runtime.
      94327e8a
    • Niklas Mischkulnig's avatar
      Migrate from box_patterns to deref_patterns (#97924) · ae622d6c
      Niklas Mischkulnig authored
      TLDR: just enable `deref_patterns` and remove the `box` syntax. And it
      just works
      
      `box_patterns` will be removed entirely in the next Rust nightly:
      https://github.com/rust-lang/rust/pull/156749
      ae622d6c