1. 13 Oct, 2026 24 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.10 · 38a8dc53
      next-js-bot[bot] authored
      38a8dc53
    • Aurora Scharff's avatar
      Update evals for stabilized navigation APIs (#100145) · dc9bfeaa
      Aurora Scharff authored
      ## Summary
      
      - require the stable `navigation()` API in the Partial Prefetching
      optimizer eval instead of accepting `unstable_navigation()`
      - keep the skill-only static-shell optimizer eval out of published
      results
      - run the empty-static-params fixture as a normal baseline/docs eval
      instead of attaching an unrelated skill
      
      The other published `prefetch()` and `navigation()` graders were already
      updated when those APIs stabilized in #99241.
      
      ## Verification
      
      - `pnpm prettier --with-node-modules --ignore-path .prettierignore
      --write evals/eval.config.json
      evals/evals/agent-051-optimize-partial-prefetching/EVAL.ts`
      - `npx eslint --config eslint.config.mjs --fix
      evals/evals/agent-051-optimize-partial-prefetching/EVAL.ts`
      - Not run: full eval execution (metadata and static grader-only changes)
      
      <!-- NEXT_JS_LLM -->
      dc9bfeaa
    • Aurora Scharff's avatar
      docs: make agent feedback command work in npm workspaces (#100135) · ec59230d
      Aurora Scharff authored
      ## Summary
      
      - Replace the managed agent-feedback command with `npx --no-install next
      internal agent-feedback-instructions`, so it resolves a
      workspace-hoisted `next` binary without downloading another version.
      - Keep the runtime generator, `create-next-app` template, docs, and
      generated-block test in sync.
      - Shorten the always-loaded retention rule while leaving detailed
      qualification guidance in the on-demand feedback protocol.
      
      Finding: https://next-maintainer-agent.vercel.tools/agent-feedback/1434
      
      ## Verification
      
      - `pnpm exec jest --runInBand
      packages/next/src/server/lib/generate-agent-files.test.ts` (15 tests)
      - `HEADLESS=true pnpm test-dev-turbo
      test/development/app-dir/agent-rules-auto-generate/agent-rules-auto-generate.test.ts`
      (16 tests)
      - `HEADLESS=true pnpm test-start-turbo
      test/production/create-next-app/index.test.ts -t "should write the agent
      feedback block"`
      - From a nested workspace package with `next` available only in the root
      `node_modules`, `NEXT_TELEMETRY_DISABLED=1 npx --no-install next
      internal agent-feedback-instructions` exits successfully.
      - `pnpm --filter=next build`
      - `pnpm --filter=create-next-app build`
      - `pnpm lint` stops on two existing `no-map-async-cell` diagnostics in
      `crates/next-napi-bindings/src/next_api/analyze.rs`.
      - `pnpm build-all` stops while parsing an existing Cargo workspace
      dependency because `default-features = false` cannot override the
      workspace default.
      
      <!-- NEXT_JS_LLM -->
      ec59230d
    • Niklas Mischkulnig's avatar
      fee0a7d9
    • Eddy (Frontend Engineer)'s avatar
      docs(cache-handlers): explain updateTags durations, fix Redis EX for Infinity (#96517) · 2f6d913d
      Eddy (Frontend Engineer) authored
      Two small gaps left on the `cacheHandlers` page after #98039 rewrote it.
      
      **`updateTags()` doesn't say what `durations` means.** The table calls
      it "optional expiration duration in seconds", but its presence is the
      signal: without it the call is an immediate invalidation (`updateTag()`,
      single-argument `revalidateTag()`); with it the tags go stale and
      entries carrying them may keep serving until `durations.expire`
      (`revalidateTag(tag, 'max')`). `revalidation-utils.ts` only passes
      `durations` when a profile resolves, so a handler that treats both cases
      the same loses stale-while-revalidate for profile-based revalidation.
      
      **The Redis example passes `entry.expire` straight to `EX`.** `EX` needs
      a positive integer and `expire` can be `Infinity` ("never expire"), so
      that call fails for such entries. The example now omits `EX` when
      `expire` isn't finite and rounds up otherwise.
      
      One file, docs only.
      
      ---
      
      History: this PR originally corrected the `get()` guidance that told
      handlers to drop entries past `revalidate`. #98039 fixed that as part of
      the page rewrite, so this PR was rebased and reduced to the two items
      above.
      2f6d913d
    • Benjamin Woodruff ‮'s avatar
      Turbopack: Use the imagesize crate to correctly size AVIF images (still no… · 1ef9f599
      Benjamin Woodruff authored
      Turbopack: Use the imagesize crate to correctly size AVIF images (still no optimization or encoding) (#99966)
      
      AVIF support is blocked on `image-rs` support (see
      https://github.com/vercel/next.js/issues/86392):
      
      - `image-rs` supports using `dav1d` for decoding, but it's a bunch of C
      and assembly and needs nasm to build in CI. nasm is tricky to install on
      all of our supported platforms.
      - `rav1d` is a pure-rust implementation (with optional assembly). We're
      okay with a perf hit and would be happy to disable assembly, but...
      - You can't just call `rav1d` directly. You need to use an mp4 container
      parser and pass that information to the codec. This isn't rocket
      science, but it's more work than we want to do in `turbopack-image`.
      - `image-rs` has an open PR for enable `rav1d`, but it hasn't had any
      progress in the last few months.
      https://github.com/image-rs/image/pull/2849
      - The current state-of-the art is
      https://github.com/kornelski/avif-decode, but that enables asm on x86-64
      with no way to disable it:
      https://github.com/kornelski/avif-decode/issues/3
      
      However, it turns out we can pull in this tiny dependency that can parse
      just the mp4 headers associated with the size information, and at least
      get the image width/height correct.
      1ef9f599
    • Jimmy Miller's avatar
      Fix Turbopack lazy dynamic-import chunk-list collisions (#99940) · f15cf85f
      Jimmy Miller authored
      ## Summary
      
      Fix development Build Errors reporting that assets with different
      content were emitted to the same output path when lazy dynamic imports
      reach a shared target through different parent chunk groups.
      
      Dynamic HMR chunk-list contents depend on the modules already available
      from the parent, but their identities omitted that availability context.
      Include the availability identity while preserving stable HMR paths and
      lazy-compilation activation keys, rather than hashing the emitted
      chunk-list contents.
      
      Add a dependency-free regression fixture with parallel page branches
      that use `next/dynamic` to import a shared target containing a nested
      `React.lazy` import. Verify HTTP success, hydration of both leaves, and
      no error overlay.
      
      ## Verification
      
      - Reproduced HTTP 500 and the chunk-list collision on `next@16.4.0`,
      `next@16.5.0-canary.5`, and the unmodified checkout.
      - Confirmed the regression test fails before the fix and passes with the
      locally rebuilt native binding.
      - `pnpm test-dev-turbo
      test/development/app-dir/lazy-dynamic-imports/lazy-dynamic-imports.test.ts`
      — all 10 tests passed with the fixed native binding.
      - Patched Streamdown reproduction returns HTTP 200, hydrates all three
      instances, and renders all three Mermaid diagrams without a Build Error.
      
      <!-- NEXT_JS_LLM -->
      f15cf85f
    • Jiwon Choi's avatar
      Turbopack: de-flake the active Tokio worker count test (#100120) · 2d5c328a
      Jiwon Choi authored
      ## What?
      
      De-flakes `turbopack-trace-utils`'s
      `tokio_workers::tests::counts_scheduler_workers_but_not_blocking_threads`,
      which failed in CI with `left: 1, right: 2`
      ([job](https://github.com/vercel/next.js/actions/runs/38377328135/job/115229618650)).
      It is a real flake, not a broken counter — the assertion raced Tokio's
      workers.
      
      ## Why?
      
      The test seeded the counter and then asserted it immediately after
      `Builder::build()`:
      
      ```rust
      set_worker_threads(2);
      let rt = builder.build().unwrap();
      assert_eq!(active_worker_threads(), 2); // ← races the workers' first park
      ```
      
      `Builder::build()` spawns the scheduler workers before it returns
      (`Launch::launch` in tokio's multi-thread scheduler), and each worker
      parks as soon as it finds an empty run queue, which runs the
      `on_thread_park` hook and decrements the counter. The value visible once
      `build()` returns is therefore whatever the workers happened to get to:
      `2` if neither has been scheduled yet, `1` if one has parked, `0` if
      both have. CI got `1`.
      
      I reproduced it by replaying that sequence against tokio 1.52.1 and
      injecting one `std::thread::yield_now()` after `build()`, which is what
      a single preemption on a loaded runner looks like: **8/400 runs observed
      `1` or `0`**, and with a 50µs sleep **100/100 observed `0`**. With no
      injected delay the window is tiny (`1` seen once in 300 runs on an idle
      box), which matches it surfacing as a one-off CI failure. The same
      harness shows the seeded count is `2` in 400/400 runs when read *before*
      the runtime is built.
      
      ## How?
      
      Nothing about the metric itself changed — the fix is to stop asserting
      things whose timing the test does not own.
      
      - The seeded count and the `park`/`unpark` arithmetic are now asserted
      **before** the runtime exists, where no other thread can touch the
      counter. That is the only race-free place to check the exact value.
      - Every expectation after the build starts from a state the test
      controls:
      - wait for the idle runtime to settle at `0` via a shared
      `wait_for_active_worker_threads` helper;
      - read the count from **inside** the blocking task, so the test's actual
      subject (a blocking thread is not counted) is checked against a
      known-zero baseline while that thread is alive, instead of only checking
      that the count came back down afterwards;
      - hold the spawned task on the barrier while the non-zero count is read
      (unchanged — this assertion was already race-free, because a worker must
      be unparked to run the task and the barrier keeps it from parking
      again);
      - wait for `0` once more at the end to confirm park/unpark stayed
      balanced.
      - The wait loop sleeps 1ms per iteration instead of `yield_now()`, so
      the waiting thread does not compete with the worker threads it is
      waiting for, and the panic message now reports the count it actually
      saw. Timeouts went from 5s to 10s, still well inside nextest's 60s
      slow-test threshold.
      
      Everything stays in one `#[test]` on purpose, and there is now a comment
      saying why: `ACTIVE_WORKER_THREADS` is process-global, so splitting this
      into several tests would make them race with each other under `cargo
      test`, which runs a binary's tests on parallel threads (nextest's
      process-per-test would hide that).
      
      No production code changed. All four call sites seed the count with the
      same worker count they configure (or tokio's default, via
      `default_worker_threads`), so park/unpark stay balanced and the counter
      cannot underflow.
      
      ## Verification
      
      - `cargo test -p turbopack-trace-utils -p turbopack-trace-server` — 73,
      47 and 25 tests passed, 0 failed.
      - Fixed test in the CI `release-with-assertions` profile: **400/400**
      passed idle, **300/300** passed under 2× CPU oversubscription.
      **500/500** in the dev profile.
      - Injected-delay harness that breaks the old ordering 8/400 times: with
      50ms delays injected at *every* step, **250/250** runs saw the seeded
      count as `2`, the count inside the blocking task as `0`, and the count
      while the task runs as `1`, with no wait-loop timeouts.
      - `cargo clippy -p turbopack-trace-utils --all-targets` and `cargo fmt
      -p turbopack-trace-utils -- --check` are clean.
      - Not run: the rest of the workspace and the JS test suites, untouched
      by a test-only change in one module.
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code)
      Co-authored-by: 's avatarvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
      2d5c328a
    • Tobias Koppers's avatar
      Turbopack: preload _app's next/dynamic chunks with _app's own availability (#100091) · 5eec1d9d
      Tobias Koppers authored
      ## Summary
      
      Fixes a Turbopack dev regression from #98823 in the Pages Router. When
      `pages/_app` renders a `next/dynamic` component, a page's SSR HTML can
      preload a chunk that 404s. This was reported in #99789, with a repro at
      [dcheng1290/next-loadable-404](https://github.com/dcheng1290/next-loadable-404).
      The component still renders, but the browser logs a failed request. This
      PR also makes Turbopack production preload `_app`'s `next/dynamic`
      chunks on every page, matching dev and webpack.
      
      **Why:** #98823 chains the `/_app` and page client module graphs in
      development. `next/dynamic` imports are collected from every layer of
      that graph, so each page's `react-loadable-manifest` now also lists
      `/_app`'s dynamic imports, but chunked with the **page's** availability.
      At runtime those imports are loaded by `/_app`'s own async loader, which
      is chunked with `/_app`'s graph and availability. The preloaded chunk
      names therefore don't match the chunks that are emitted and requested.
      
      In production, `/_app`'s dynamic imports were only listed in
      `server/pages/_app/react-loadable-manifest.json`, which page renders
      don't read, so they were never preloaded.
      
      **How:** a Pages-only helper in `crates/next-api/src/pages.rs`
      (`page_next_dynamic_chunks`), used for every page except `/_app`:
      - it chunks `/_app`'s dynamic imports with the `/_app` endpoint's client
      module graph and client availability, which is exactly what `/_app`
      itself lists;
      - it chunks the page's own imports as before, with `/_app`'s filtered
      out (in per-page/dev mode they are reachable from the page's chained
      graph);
      - it merges both into the page's manifest.
      
      The generic collector in `module_graph.rs` is untouched, and so is App
      Router.
      
      This should be backported to `releases/lts/active` together with #98823
      (backport PR #100008).
      
      ## Verification
      
      - New e2e suite `test/e2e/pages-app-next-dynamic-preload`, based on the
      repro. It checks that:
      - every `/_next/static` asset in the SSR HTML of `/` and `/other`
      returns 200;
        - the `_app` dynamic component renders;
        - both pages preload the same non-empty set of `_app` dynamic chunks.
      - The suite fails without the fix in Turbopack dev (a 404 asset). With
      the fix it passes in Turbopack dev and start and in webpack dev and
      start, using a locally built native binary.
      - Existing suites pass in Turbopack dev and start: `next-dynamic`,
      `next-dynamic-css`, `next-dynamic-lazy-compilation`,
      `pages-app-availability-boundary`, `app-document-import-order` (#99910),
      `app-dir/dynamic` and `app-dir/dynamic-import`.
      - Manual check, using the repro with a headless browser in dev and in
      production:
        - there are no failed requests or console errors on either page;
      - production manifests list `_app`'s entry with the chunk `_app` itself
      uses.
      - `cargo clippy -p next-api` and `cargo fmt --check` pass.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 652922cb-dc34-493d-9be5-c241a5164cad -->
      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>
      5eec1d9d
    • Tobias Koppers's avatar
      test: deflake app-basepath external redirect test (#100096) · d735dbab
      Tobias Koppers authored
      ### What?
      
      Deflakes `test/e2e/app-dir/app-basepath` › "should redirect externally
      when encountering absolute URLs on the same host outside the basePath".
      It was flaky on 6 of 23 canary commits, across dev, turbopack dev, cache
      components dev and prod jobs.
      
      ### Why?
      
      `/outsideBasePath` is rewritten to the third-party host
      `https://example.vercel.sh/`. The test clicked the button, then waited
      with the default 3s `retry()` for `browser.url()` to change. The browser
      only updates its URL once the proxied response from example.vercel.sh
      comes back. So the test was timing the third-party host, not Next.js.
      
      In every failing run, the server action `POST` finished in under 10ms
      and then the URL was still `…/base/client` after the retry gave up (e.g.
      [this
      run](https://github.com/vercel/next.js/actions/runs/38228927483/job/114744111096)).
      Locally, if the rewrite points at an upstream that waits 3s before
      answering, the old test fails the same way. With 100ms it passes.
      
      ### How?
      
      - Wait for the browser to send the document `GET /outsideBasePath`,
      which only depends on Next.js. The test checks the exact `[POST
      /base/client, GET /outsideBasePath]` pair.
      - Then read each response from its request (`request.response()`) and
      keep the existing checks:
        - the POST returns `x-action-redirect` and no `location`;
        - the GET returns 200;
        - the browser ends up on `/outsideBasePath`.
      
      The rewrite and deploy coverage stay as they are. No retry window was
      made longer. Waiting for the upstream response is limited only by the
      normal test timeouts.
      
      ### Verification
      
      - Full suite, with a local upstream that waits 3s before answering
      (scratch change, not committed): passes 13/13 with `pnpm test-dev-turbo`
      and `pnpm test-start-turbo`. The old test fails in that setup.
      - Full suite, with the real example.vercel.sh rewrite: passes 13/13 with
      `pnpm test-dev-turbo` and `pnpm test-start-turbo`.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 8ed51691-b715-4d15-8574-79aa8e971ffd -->
      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>
      d735dbab
    • Tobias Koppers's avatar
      test: install local Next.js sibling packages in CNA tests (#100062) · 5591d800
      Tobias Koppers authored
      ### What?
      
      Makes create-next-app and ESLint config tests install sibling Next.js
      workspace packages (`@next/env`, `@next/eslint-plugin-next`) from their
      local packed tarballs instead of the npm registry.
      
      ### Why?
      
      On release commits, attempt 1 of build-and-test fails across ~58 jobs
      (Linux, Windows, Rspack) because the freshly bumped `@next/env` /
      `@next/eslint-plugin-next` versions aren't on npm yet when the tests
      install. Examples:
      [v16.5.0-canary.7](https://github.com/vercel/next.js/actions/runs/38004324568),
      [v16.5.0-canary.8](https://github.com/vercel/next.js/actions/runs/38094923448).
      The errors are npm `notarget`, pnpm `ERR_PNPM_NO_MATCHING_VERSION`, yarn
      `YN0082` and bun `No version matching`.
      
      There were two gaps:
      
      - CNA already installs direct dependencies (`next`,
      `eslint-config-next`, `next-rspack`) from `NEXT_TEST_PKG_PATHS`, but not
      their transitive workspace dependencies.
      - `createNextInstall` already overrides every packed workspace package,
      but `@next/eslint-plugin-next` had no `pack-for-isolated-tests` script,
      so it was never packed.
      
      This complements #98412, which publishes companion packages in
      dependency order and makes release CI wait for npm. This PR removes the
      npm dependency for these tests, so they don't need to wait at all.
      
      ### How?
      
      - Add `pack-for-isolated-tests` to `@next/eslint-plugin-next`.
      - When `NEXT_TEST_PKG_PATHS` is set (tests only), CNA points the
      workspace companions of its direct dependencies at their local tarballs:
      `next` → `@next/env` and `eslint-config-next` →
      `@next/eslint-plugin-next`. A companion is only added when its parent is
      a direct dependency, so a project without ESLint doesn't get the ESLint
      plugin override. Overriding every packed package doesn't work, because
      Yarn Classic resolves and engine-checks every `resolutions` entry even
      when nothing depends on it. That pulled `eslint-config-next`'s
      dependency tree into `--no-linter` projects and failed on Node 20.9. The
      overrides are written as:
        - npm/Bun: `overrides`
        - Yarn/Bun: `resolutions`
        - pnpm v10+: `overrides` in `pnpm-workspace.yaml`
        - pnpm v9: `pnpm.overrides` in `package.json`
      - Without `NEXT_TEST_PKG_PATHS`, CNA output is unchanged.
      
      ### Verification
      
      - Bumped `next`, `@next/env`, `@next/eslint-plugin-next` and
      `eslint-config-next` locally to an unpublished version
      (`99.99.99-test.0`) and packed them.
        - Before: CNA installs fail with npm, pnpm 9/10, Yarn Classic and Bun.
      - After: all five succeed, and both sibling packages are installed at
      `99.99.99-test.0`.
      - With the same unpublished versions,
      `test/production/eslint-config-next/eslint-config-next.test.ts` goes
      from 5/5 failures to 5/5 passes.
      - Added regression tests to
      `test/production/create-next-app/eslint-config.test.ts`. They check npm,
      Yarn, Bun, pnpm 9, pnpm 10 and pnpm 11, including a Windows-style path
      in pnpm YAML. They also check that packed packages outside the project's
      dependencies (e.g. `@next/mdx`, `next-rspack`) are never overridden, and
      that a Biome project only gets `@next/env`.
      - `test/production/create-next-app/package-manager/yarn.test.ts` passes
      on Node 20.9.0, the CI version.
      - Without `NEXT_TEST_PKG_PATHS`, 16 generated `package.json` /
      `pnpm-workspace.yaml` files are byte-identical to before (npm, pnpm
      9/10/11, Yarn and Bun, each with ESLint and Biome).
      - The existing pnpm skip-install workspace tests pass, and CNA npm/pnpm
      installs with normal versions use the local sibling packages.
      - `pnpm typescript` passes.
      - Not run: native Windows execution and the full CI matrix (left to CI).
      The two existing npm `--example` tests couldn't run locally because the
      sandbox can't fetch the GitHub example.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet d5124198-08c9-4033-98a2-caef41e1b6fd -->
      
      ---------
      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>
      5591d800
    • Luke Sandberg's avatar
      turbopack-ecmascript-runtime: simplify the shared HMR module instantiation (#99671) · d6fdc60a
      Luke Sandberg authored
      ## What
      
      Refactor how HMR runtimes instantiate modules to reduce stack depth.
      
      Instead of `instantiateModule` calling `instantiateModuleShared` and
      passing 3 callbacks. Instead define two new global functions that each
      runtime (browser and node) must define. The refactored
      `instantateModule` can now be shared by delegating the per-runtime logic
      to the global hooks.
      
      Additionally to keep the stack frame for `instantiateModule` small,
      setup work is extracted into a new helper function `createDevModule`.
      
      Finally, simplify the runtime by preferring to reference common globals
      over threading parameters around and centralizing configuration where
      possible
      
      # Why
      
      The dev mode runtimes were adding lots of overhead that would consume
      stack space, limiting how deep evaluation could get.
      
      
      Maximum depth of a chain of trivial modules before a `RangeError`, using
      the Node.js runtime generated from these sources on Node 20.11's default
      stack:
      
      | Node.js runtime | `import` | `require` |
      |---|---|---|
      | dev, before | 795 | 820 |
      | dev, after | 1458 | 1544 |
      | production | 1591 | 1694 |
      
      For comparison, the same chain loaded by Node.js itself, one file per
      level. The Turbopack rows are re-run on each version:
      
      | | Node 20.19 | Node 22.20 | Node 24.21 |
      |---|---|---|---|
      | native CJS `require` | 750 | 521 | 617 |
      | native ESM `import` | 2116 | 2295 | 702 |
      | native `require(esm)` | 1024 | 1110 | 707 |
      | Turbopack dev, before | 795 | 750 | 852 |
      | Turbopack dev, after | 1459 | 1312 | 1492 |
      | Turbopack production | 1591 | 1418 | 1613 |
      
      <!-- NEXT_JS_LLM -->
      d6fdc60a
    • Luke Sandberg's avatar
      Don't blame the Pages Router for next/headers imported through a Client Component (#100087) · ab5db580
      Luke Sandberg authored
      ## Summary
      
      When a Client Component imports a module outside `app/` (e.g.
      `lib/shared.js`) that depends on `next/headers`, the error said the API
      was being used "in the Pages Router", even in apps with no `pages`
      directory. The RSC transform picked the message by whether the file is
      inside `appDir`, but a module outside `app/` can still be part of the
      App Router graph.
      
      The transform now takes an explicit `isAppRouter` option. Webpack sets
      it from the bundle layer, and Turbopack from whether the context has an
      `appDir` (only the Pages Router context passes none). App Router graphs
      get the Client Component message; Pages Router files still get the Pages
      Router one.
      
      ## Verification
      
      - `cargo test -p next-custom-transforms` (no existing fixture outputs
      changed)
      - `pnpm test-dev-turbo` / `pnpm test-dev-webpack` on
      `test/development/acceptance/server-component-compiler-errors-in-pages.test.ts`
      and `test/e2e/app-dir/next-after-pages/index.test.ts`, which still
      assert the Pages Router message for Pages Router files
      
      <!-- NEXT_JS_LLM -->
      
      ---------
      Co-authored-by: 's avatarvercel-gh-bot-2[bot] <282331341+vercel-gh-bot-2[bot]@users.noreply.github.com>
      ab5db580
    • Niklas Mischkulnig's avatar
      chore: Make Rust warnings non-fatal unless on CI (#99939) · 65760591
      Niklas Mischkulnig authored
      Previously, every warning (e.g. unused import or variable) would fail
      local Rust builds
      Only do that on CI
      65760591
    • Niklas Mischkulnig's avatar
      Fix rustdoc warnings (#100036) · 3934c3c6
      Niklas Mischkulnig authored
      Some are typos, but most of these hinge around referring to non-public
      types in the doc comments of public types
      3934c3c6
    • Niklas Mischkulnig's avatar
      Durable use cache: ignore binding usage when traversing (#100128) · 7fe50643
      Niklas Mischkulnig authored
      Inner graph tree shaking (`removeUnusedImports`) caused different code
      hashes across endpoints:
      
      ```ts
      // actions.ts
      export a(){ "use cache"; return 123; }
      
      import other from "other";
      export b(){ "use cache"; return other(); }
      ```
      
      1. On API route foo, you import `a` from `actions.ts`. So the reference
      `actions.ts -> other` is removed by inner graph tree shaking.
      2. Then on Page route bar, you import `b` from `actions.ts`. So the
      reference `actions.ts -> other` is not removed.
      3. Now the `codeHash` for server action `actions.ts#a` is different
      across the Page/Route because the module subgraph is difference across
      the two.
      7fe50643
    • Niklas Mischkulnig's avatar
      chore: Fix agents instruction about rebuilding test changes (#100116) · e72e68af
      Niklas Mischkulnig authored
      You don't need to run `pnpm build` or `pnpm dev` after changing tests.
      Not sure why the AGENTS.md file said that
      e72e68af
    • Niklas Mischkulnig's avatar
      chore: Prevent concurrent pack-for-isolated-tests (#100118) · a7d66933
      Niklas Mischkulnig authored
      I frequently run into these problems, if you kick off multiple tests in
      parallel that both try to pack the tarball and then overwrite each other
      ```
      Found 8 packed tarballs: eslint-config-next, @next/font, next, @next/bundle-analyzer, @next/env, @next/mdx, next-rspack, @next/third-parties
      {
        swcNativeDirectory: '.../next.js/yokohama/packages/next-swc/native',
        swcWasmDirectory: undefined
      }
      created next.js install, writing test files
      Progress: resolved 1, reused 0, downloaded 0, added 0
       ERR_PNPM_Z_DATA_ERROR  Failed to add tarball from ".../next.js/yokohama/packages/next/packed.tgz" to store: incorrect header check
      
      This error happened while installing a direct dependency of /private/var/folders/s5/952zt8mn6ms05__7r749hkjm0000gn/T/next-install-0404258370fcd6667195d6fb8d54a920e1ef9e12fb007289b8f908c3bddf0a0c
      Failed to create next instance Error: Command failed with exit code 1 (EPERM): pnpm install --strict-peer-dependencies=false --no-frozen-lockfile --config.cacheDir=/private/var/folders/s5/952zt8mn6ms05__7r749hkjm0000gn/T
          at makeError (.../next.js/yokohama/node_modules/.pnpm/execa@2.0.3/node_modules/execa/lib/error.js:58:11)
          at handlePromise (.../next.js/yokohama/node_modules/.pnpm/execa@2.0.3/node_modules/execa/index.js:112:26)
          at processTicksAndRejections (node:internal/process/task_queues:104:5)
          at installDependencies (.../next.js/yokohama/test/lib/create-next-install.js:32:3)
          at Span.traceAsyncFn (.../next.js/yokohama/packages/next/src/trace/trace.ts:156:14)
          at .../next.js/yokohama/test/lib/create-next-install.js:409:9
          at Span.traceAsyncFn (.../next.js/yokohama/packages/next/src/trace/trace.ts:156:14)
          at createNextInstall (.../next.js/yokohama/test/lib/create-next-install.js:237:10)
          at .../next.js/yokohama/test/lib/next-modes/base.ts:410:13
          at Span.traceAsyncFn (.../next.js/yokohama/packages/next/src/trace/trace.ts:156:14)
          at NextDevInstance.createTestDir (.../next.js/yokohama/test/lib/next-modes/base.ts:258:5)
          at NextDevInstance.setup (.../next.js/yokohama/test/lib/next-modes/next-dev.ts:22:5)
          at .../next.js/yokohama/test/lib/e2e-utils/index.ts:330:7
          at Span.traceAsyncFn (.../next.js/yokohama/packages/next/src/trace/trace.ts:156:14)
          at createNext (.../next.js/yokohama/test/lib/e2e-utils/index.ts:294:12)
          at Object.<anonymous> (.../next.js/yokohama/test/lib/e2e-utils/index.ts:406:18) {
        command: 'pnpm install --strict-peer-dependencies=false --no-frozen-lockfile --config.cacheDir=/private/var/folders/s5/952zt8mn6ms05__7r749hkjm0000gn/T',
        exitCode: 1,
        exitCodeName: 'EPERM',
        stdout: undefined,
        stderr: undefined,
        failed: true,
        timedOut: false,
        isCanceled: false,
        killed: false,
        signal: undefined
      }
      destroyed next instance: 1.841ms
      FAIL Turbopack test/e2e/app-dir/build-cache-handlers/build-cache-handlers.test.ts (17.715 s)
        build-cache-handlers
          ✕ uses build overrides for prerendering, but not in development
          ✕ uses build overrides in generateStaticParams
          ✕ uses runtime handlers for requests
      
        ● build-cache-handlers › uses build overrides for prerendering, but not in development
      
          Command failed with exit code 1 (EPERM): pnpm install --strict-peer-dependencies=false --no-frozen-lockfile --config.cacheDir=/private/var/folders/s5/952zt8mn6ms05__7r749hkjm0000gn/T
      
            30 |   }
            31 |
          > 32 |   await execa('pnpm', args, {
               |   ^
            33 |     cwd,
            34 |     stdio: ['ignore', 'inherit', 'inherit'],
            35 |   })
      
            at makeError (../node_modules/.pnpm/execa@2.0.3/node_modules/execa/lib/error.js:58:11)
            at handlePromise (../node_modules/.pnpm/execa@2.0.3/node_modules/execa/index.js:112:26)
            at installDependencies (lib/create-next-install.js:32:3)
      
      ```
      a7d66933
    • Tobias Koppers's avatar
      Split filesystem-cache e2e test into multiple suites (#100111) · 6e107283
      Tobias Koppers authored
      ### What?
      
      Splits `test/e2e/filesystem-cache/filesystem-cache.test.ts` into four
      test files that share one helper module:
      
      | File | Tests (both cache states) |
      |---|---|
      | `filesystem-cache-loaders.test.ts` | loader caching +
      `turbopack-persistence` trace spans |
      | `filesystem-cache-app-changes.test.ts` | change while stopped: RSC,
      RCC, Pages, rename app page |
      | `filesystem-cache-config-changes.test.ts` | change while stopped:
      loader, next config, env var |
      | `filesystem-cache-combined-changes.test.ts` | all changes combined |
      
      Test titles, assertions, timeouts, and skip and deploy gating stay the
      same; the tests are only moved between files.
      
      ### Why?
      
      This file was the slowest in the Turbopack shards. In recent canary
      `build_and_test` runs it took about 650–660s in `test turbopack dev` and
      380–640s in `test turbopack production`. CI distributes tests file by
      file, so this one file kept a single shard running long after the others
      had finished. In one run that dev shard took 18 min, while the others
      took 9–13 min. With four files, CI can spread this work across shards.
      
      ### How?
      
      - `filesystem-cache-helpers.ts` holds the shared setup: `nextTestSetup`
      with the existing env, start/stop/restart helpers, cache size
      measurement, the change definitions, and the "change files while
      stopped" test body. Each test file keeps its own `describe` blocks, so
      the `@force-gate !deploy` pragma still attaches directly to them.
      - **Explicit cache warm-up:** in the single file, the loader test ran
      first in each suite and warmed the cache as a side effect. Without it,
      the first cache-enabled change test started from a cold cache. In
      production, the cache then grew about 11% and failed the unchanged 10%
      size limit. Cache-enabled suites that register change tests now warm the
      cache explicitly in `beforeAll` (visit the same pages, then restart
      twice). This restores the old starting state without loosening the
      assertion.
      - The fixture's `tsconfig.json` excludes the helper so `next build`
      doesn't type-check it (it imports test-only modules).
      - The Rspack dev and build manifests list the same 19 test titles, now
      under the new file names.
      
      Follow-up, not addressed here: in dev mode the cache-size checks read
      `.next/cache/turbopack`, which stays empty, so those size assertions
      pass trivially. This predates the split.
      
      ### Verification
      
      - `pnpm test-dev-turbo` and `pnpm test-start-turbo` on each new file:
      all 19 tests pass in both modes. Local per-file times were about
      80–295s.
      - `pnpm test-dev-webpack` on the loaders file: its 3 tests are still
      skipped, as before.
      - The titles reported at runtime match the original 19, in both modes,
      and match both manifests.
      - `pnpm typescript`, prettier, and eslint pass.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet f50dbb36-f025-48a8-bf00-21e6c1a76603 -->
      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>
      6e107283
    • Joseph's avatar
      docs: update links to demos moved to the nextjs org (#100119) · a5ab0b1f
      Joseph authored
      Update links to demos moved to the nextjs org
      a5ab0b1f
    • Tobias Koppers's avatar
      test: allow custom webpack deployments to complete (#100054) · 5d764966
      Tobias Koppers authored
      ### What?
      
      Gives the `--custom-webpack` e2e tests that start their own Next.js
      instance a 240-second per-test timeout, matching the existing `explicit
      application directory` test in the same file. The tests are the
      shadowed-webpack test, the missing-webpack error test, and both
      conflicting-bundler-flag tests. Test bodies and assertions are
      unchanged, and deploy mode keeps running them.
      
      ### Why?
      
      `custom-webpack.test.ts` (added in #99234) fails every attempt in Vercel
      deploy tests on v16.5.0-canary.7 and canary.8 with `Exceeded timeout of
      60000 ms` in `with a shadowed webpack and no pnpm hoisting`:
      
      -
      https://github.com/vercel/next.js/actions/runs/38096257736/job/114359133787
      -
      https://github.com/vercel/next.js/actions/runs/38006180482/job/114077823665
      
      These suites use `skipStart`, so the instance starts inside the test
      rather than in setup. In deploy mode, starting means waiting for the
      whole Vercel deployment (install, build, deploy; about 60–90 s in these
      runs). The e2e harness gives each test 60 s unless the test sets its own
      timeout. The shadowed-webpack test is cut off at 60 s while its
      deployment is still building. The explicit-application-directory test
      passes (61–88 s) only because it already has a longer timeout. The other
      three tests pass, but at 45–57 s, close enough to fail next.
      
      ### How?
      
      A per-test timeout fits the file's existing convention and keeps
      deployment coverage. Skipping in deploy mode would remove the only
      deployed check that the app's own webpack is used, and `test/AGENTS.md`
      discourages it. Moving the start into `beforeAll` would restructure
      these suites, which keep the start inside the test because each test
      sets up its own preconditions first. The trade-off is that a real hang
      in these tests now fails after up to 4 minutes instead of 1.
      
      ### Verification
      
      - Confirmed the root cause against both job logs and the e2e/deploy
      harness
      - Compared the file's test registrations before and after: same 8 tests
      with unchanged bodies, exactly 4 new timeouts, and every test that
      starts an instance itself is covered
      - `prettier --check` (repo-pinned version) and `git diff --check`
      - Not run: eslint / type-check (no workspace dependencies in the
      sandbox) and local or deploy e2e (no build outputs or Vercel
      credentials). The deploy run still needs to be confirmed in the deploy
      test workflow.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet db94cc8e-c6ca-4069-9894-120a370db8c4 -->
      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>
      5d764966
    • Tobias Koppers's avatar
      Turbopack: fix edge route handlers when cacheHandlers is configured (#100046) · c420af22
      Tobias Koppers authored
      ### What?
      
      Fixes Turbopack production and dev builds of App Router route handlers
      with `export const runtime = 'edge'` when `cacheHandlers` is configured.
      These builds currently fail with `edge-app-route.js: Expected ';', '}'
      or <eof>`. Webpack builds of the same app already work.
      
      ### Why?
      
      The webpack loader and Turbopack both fill the
      `edgeCacheHandlersRegistration` injection point in the shared
      `edge-app-route.ts` template, which sits at statement position after
      `const edgeCacheHandlers = {}`.
      - **webpack** emits assignment statements.
      - **Turbopack** (`wrap_edge_route` in
      `crates/next-core/src/next_app/app_route_entry.rs`) emitted
      object-literal property fragments, which don't parse at statement
      position.
      
      Existing coverage missed this because the edge fixture in
      `cache-handlers-upstream-wiring` only sets the singular `cacheHandler`.
      The loop that generates these entries never ran for an edge route.
      
      ### How?
      
      - **Turbopack codegen:** Turbopack now emits one assignment per
      configured kind (`edgeCacheHandlers[<kind>] = cacheHandlerN`), matching
      the webpack loader. Each kind is still serialized with `serde_json`. The
      template and the webpack loader are unchanged, so both bundlers keep
      sharing the same template contract.
      - **Regression fixture:** the new `edge-with-cache-handlers` fixture has
      two distinct handler modules (`default` and `custom`), one force-dynamic
      edge route and no edge page. It pins `cacheComponents: false` and
      `experimental.cachedNavigations: false`, because Cache Components is not
      supported on the edge runtime. Without both pins, the experimental CI
      shards would turn these flags on through env defaults, and the fixture
      would fail config validation or the build.
      - **What the test checks:** the route reads the cache-handler registry
      that `EdgeRouteModuleWrapper` fills before invoking it, and returns each
      handler's marker. The test asserts both markers over HTTP, so it fails
      if the build breaks or if either kind is missing or swapped.
      - The suite has no gates. The fixture is a valid edge app in every
      shard, so the assertions run everywhere, including deploy.
      - **Limits:** the test proves registration only. It doesn't exercise
      `'use cache'` hits or revalidation on edge.
      
      ### Verification
      
      | Run | Result |
      |---|---|
      | New test, `test-start-turbo`, unfixed published binary | ❌ fails with
      the parse error above, as expected |
      | New test, `test-start-turbo`, local native build with the fix | ✅
      passes |
      | Existing edge test (`cacheComponents disabled, edge app router`), same
      fixed build | ✅ passes |
      | New test, `test-start-webpack` | ✅ passes |
      | New test, `test-dev-turbo` | ✅ passes |
      | New test with the experimental (cache-components) CI env,
      `test-start-turbo` and `test-dev-turbo` | ✅ passes |
      | Standalone repro (published canary.8 + fixed native binary), `next
      build` + `next start`, `GET` the edge route | ✅ builds and returns the
      expected JSON |
      
      Not run locally: deploy-mode tests (they run in CI).
      
      Fixes #99894
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 826df9e4-b701-4396-9634-0b96a03345e7 -->
      
      ---------
      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>
      c420af22
    • mugi-uno's avatar
      fix(next-code-frame): snap visible window to char boundaries (#92646) · b0df1ae0
      mugi-uno authored
      ### What?
      
      Fix a panic in `next-code-frame` when rendering error overlays for
      source code containing multi-byte characters (e.g. CJK).
      
      ### Why?
      
      `extract_highlights()` used display-column values as byte offsets when
      computing the per-line scan window. For multi-byte characters (e.g. CJK:
      3 bytes / 2 display columns), the window end could land inside a
      multi-byte character. `scan_template()`'s fallback then emitted spans
      with non–char-boundary offsets, causing `apply_line_highlights()` to
      panic when slicing the visible content string.
      
      The crash depends on terminal width — different widths shift where the
      scan window lands, so the same source may or may not trigger it.
      
      ### How?
      
      Snap the computed byte range to character boundaries using
      `floor_char_boundary` / `ceil_char_boundary` in `extract_highlights()`.
      Since the visible window is only an optimisation hint for the scanner,
      widening it slightly has no correctness impact.
      
      Fixes #92641
      
      <!-- NEXT_JS_LLM_PR -->
      
      ---------
      Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <lukesandberg@users.noreply.github.com>
      b0df1ae0
    • Daniel Caspi's avatar
      Resolve relative imports in `next.config.ts` from the config directory (#99743) · c632caf3
      Daniel Caspi authored
      ### What?
      
      Relative imports in `next.config.ts` resolve against `process.cwd()`
      instead of the config file's directory. Building or starting a project
      from any other directory (for example `next build app` from a monorepo
      root, or a tool that calls `loadConfig` for a project) either fails with
      `Cannot find module './...'`, or, if a file happens to exist at the same
      relative path under the working directory, silently loads that file
      instead.
      
      ### Why?
      
      With the default SWC loader, the compiled config is loaded by
      `requireFromString` in
      `packages/next/src/build/next-config-ts/require-hook.ts`. It creates a
      `Module` and sets `paths`, but never sets `filename`. `new Module(id,
      parent)` only sets `id`, and `_compile` does not set `filename`. When
      the parent module has no filename, Node's `Module._resolveLookupPaths`
      resolves relative requests against `'.'`, which is `process.cwd()`.
      `m.paths` only covers bare package lookups, which is why `node_modules`
      imports keep working.
      
      ### How?
      
      Set `m.filename = filename` before `m._compile(...)`, so relative
      requires resolve from `dirname(filename)`, the project directory.
      
      ### Tests
      
      Added `test/unit/isolated/next-config-ts-relative-imports.test.ts` with
      fixtures under `test/unit/isolated/_resolvedata/`. It loads a
      `next.config.ts` that imports `./lib/origin` with three working
      directories:
      
      - the config directory (baseline, already passes)
      - a directory with no `./lib/origin` (failed before with
      `MODULE_NOT_FOUND`)
      - a directory with its own `./lib/origin` (before, loaded that file and
      returned `'cwd'` instead of `'config-dir'`)
      
      The test runs `loadConfig` in a child process. Under jest, `loadConfig`
      loads the config with `require()` (`__NEXT_TEST_MODE === 'jest'`) and
      never reaches `transpileConfig`, so an in-process test passes with or
      without the fix. The child process also gives each case its own working
      directory and module cache, and sets
      `__NEXT_NODE_NATIVE_TS_LOADER_ENABLED=false` to make sure the SWC path
      is exercised.
      
      Without the fix, 2 of the 3 tests fail; with it, all pass. The existing
      `test/unit/isolated/config.test.ts` and the
      `test/e2e/app-dir/next-config-ts/nested-imports` and
      `import-from-node-modules` suites still pass.
      
      Fixes #99742
      c632caf3
  2. 12 Oct, 2026 16 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.9 · f1069947
      next-js-bot[bot] authored
      f1069947
    • Jiwon Choi's avatar
      Gate upgrade reminder rules with agentUpgrade (#99990) · e7feae7d
      Jiwon Choi authored
      ### Why?
      
      Agents can reject Next.js upgrade reminders as instructions from build
      output or omit the notice after completing the original task. Upgrade
      delegation should follow the existing `experimental.agentUpgrade` policy
      independently of documentation and feedback rules.
      
      ### How?
      
      Add a separate managed `nextjs-agent-upgrade` block to `AGENTS.md`.
      Enabled policies generate it for detected agents; `agentUpgrade: false`
      removes it during `next dev`, preserving other instructions. Include the
      block in default create-next-app projects and preload the installed
      candidate's upgrade block in nudge fixtures while keeping `agentRules:
      false`.
      
      Validation: 14 generator unit tests, 16 dev lifecycle integration tests,
      and 3 create-next-app AGENTS.md tests passed; Next.js/create-next-app
      builds and ESLint passed. Fresh-head upgrade evals are pending; CLI
      reminders, user prompts, and judges are unchanged.
      
      <!-- NEXT_JS_LLM -->
      e7feae7d
    • Jiwon Choi's avatar
      Enable network access for Codex upgrades (#100074) · cb328645
      Jiwon Choi authored
      ### Why?
      
      Codex's workspace sandbox can block package downloads, leaving an agent
      upgrade unable to install dependencies or verify the app.
      
      ### How?
      
      Enable network access for newly launched Codex upgrade sessions while
      preserving their filesystem sandbox and approval settings. Existing
      agent sessions and Claude launches keep their current settings.
      
      <!-- NEXT_JS_LLM -->
      cb328645
    • Jiwon Choi's avatar
      Narrow upgrade eval triggers (#100075) · 500ed3f2
      Jiwon Choi authored
      ### Why?
      
      Broad path filters run upgrade evals on unrelated configuration and
      dependency changes, adding unnecessary CI work to PR updates.
      
      ### How?
      
      Limit automatic runs to upgrade implementation, its eval suite, and
      directly used eval infrastructure. Broader configuration, dependency,
      documentation, and shared codemod changes can use the existing manual
      trigger.
      
      <!-- NEXT_JS_LLM -->
      500ed3f2
    • Aurora Scharff's avatar
      docs: update links for transferred demo repositories (#100041) · 73ab7c5d
      Aurora Scharff authored
      ## Summary
      
      Update documentation links for `async-react-demo` and
      `next-spa-patterns` after moving the repositories from `vercel-labs` to
      the `nextjs` organization. The existing live demo URLs remain unchanged.
      
      ## Verification
      
      - `pnpm prettier --with-node-modules --ignore-path .prettierignore
      --write <changed files>`
      - `npx eslint --config eslint.config.mjs --fix <changed files>`
      - Verified the destination repositories are public under `nextjs`
      
      <!-- NEXT_JS_LLM -->
      73ab7c5d
    • Luke Sandberg's avatar
      Make it possible to disable `turbopackGc` (#100067) · 1d31d04a
      Luke Sandberg authored
      whups
      1d31d04a
    • Niklas Mischkulnig's avatar
      fix: use EntryKeySide in EntryKey side field (#100053) · 6dd25d96
      Niklas Mischkulnig authored
      ## Summary
      
      The serialized `side` field in `EntryKey`
      (`packages/next/src/shared/lib/turbopack/entry-key.ts`) was declared
      with `${EntryKeyType}` instead of `${EntryKeySide}`, so the type claimed
      `side` could be `"app" | "pages" | "root" | "assets"` while
      `getEntryKey` actually produces `"client" | "server"`. The `as EntryKey`
      assertion on `JSON.stringify` masked the mismatch. Type-only fix;
      runtime serialization is unchanged and no tests were added per the
      agreed scope.
      
      ## Verification
      
      - `pnpm --filter=next types` (after workspace bootstrap via `pnpm
      build`)
      - `pnpm prettier --check
      packages/next/src/shared/lib/turbopack/entry-key.ts`
      - Scratch tsc check (not committed): original type accepts `side:app`
      literals; corrected type rejects them while still accepting keys from
      `getEntryKey`
      
      <!-- NEXT_JS_LLM -->
      
      <!-- fleet 18629715-7a2d-41b0-8706-8b3f9db46fcc -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      6dd25d96
    • Niklas Mischkulnig's avatar
      fix: use removePathPrefix instead of regex (#100063) · a9437d1d
      Niklas Mischkulnig authored
      This unescaped regex looked dangerous (I didn't run into any particular
      bugs).
      Just replace it with some equivalent logic without needing a regex
      a9437d1d
    • Niklas Mischkulnig's avatar
      Fix root params detection on Windows (#100065) · 5ce27fa7
      Niklas Mischkulnig authored
      Fix `next/root-params` getter generation on Windows with webpack. Native
      backslashes were treated as part of a route segment instead of
      separators, causing missing or malformed getters.
      
      Examples before this fix (paths relative to `app`):
      
      | Root layout | Extracted parameter names | Expected |
      | ---------------------------- | ------------------------- |
      ---------------- |
      | `[lang]\[region]\layout.tsx` | `lang]\[region` | `lang`, `region` |
      | `(group)\[lang]\layout.tsx` | None | `lang` |
      | `[lang]\static\layout.tsx` | None | `lang` |
      
      Normalize separators before parsing the route, and add the existing
      root-params getters e2e suite to Windows production CI with webpack.
      5ce27fa7
    • Niklas Mischkulnig's avatar
      Durable use cache: exclude context for path and code hashes (#99898) · a7fd0aa6
      Niklas Mischkulnig authored
      Previously, this
      - hashed the layer of the imported modules, which caused problems with
      app-rsc and app-router, because those would hash to different values,
      and then `use cache: remote` across app-rsc and app-router would end up
      with different cache entries (even within the same deployment)
      - hashed the JS with numeric module ids (which are inherently unstable)
      which also again included the layer (app-rsc vs app-router again) and
      also included `unused_references()` (which are also somewhat unstable)
      
      This might make the build slightly slower (because of the differing
      chunking_context and thus non-memoized code generation)
      a7fd0aa6
    • Niklas Mischkulnig's avatar
      Expand durable use cache cross-deployment test coverage (#99900) · 85323a48
      Niklas Mischkulnig authored
      Expand cross-deployment durable cache coverage
      - Route Group segments were previously untested (and were partially
      broken until https://github.com/vercel/next.js/pull/99881)
      - app-rsc vs app-route was previously causing cache misses (test will
      get enabled in https://github.com/vercel/next.js/pull/99898)
      85323a48
    • Niklas Mischkulnig's avatar
      Ensure `workStore.page` is unnormalized for generateStaticParams (#99881) · 3dfe55b5
      Niklas Mischkulnig authored
      During `generateStaticParams`, `workStore.page` was normalized. App Page
      rendering has the original app entry path in there. So this was
      inconsistent before.
      
      This restores durability metadata lookups for cached functions called by
      `generateStaticParams`, allowing reuse across builds with
      `durableUseCacheEntries`.
      
      The next PR in the stack adds a lot of tests, including one for this.
      
      Ideally, this would be testable outside of `durableUseCacheEntries`
      though
      
      https://github.com/vercel/next.js/pull/99912 contains a full e2e test
      requiring this
      
      ------
      
      Server Action failure during `generateStaticParams`
      
      Root cause: `generateStaticParams` uses the normalized URL route as the
      page identity, so cached Server Action deserialization looks up the
      wrong manifest entry.
      
      **Failure chain**
      
      1. The fixture returns `getSlug` from a `'use cache'` function. Reading
      that cached result requires Flight to deserialize the Server Action—even
      on a cache miss.
      
      2. [`build/utils.ts:924`](packages/next/src/build/utils.ts#L924) loads
      the correct original page:
      
         ```text
         /(group)/static-params/[slug]/page
         ```
      
      But at [line 1013](packages/next/src/build/utils.ts#L1013), it passes
      the normalized `page` to `buildAppStaticPaths`:
      
         ```text
         /static-params/[slug]
         ```
      
      3.
      [`build/static-paths/app.ts:961`](packages/next/src/build/static-paths/app.ts#L961)
      uses that value to create the work store.
      
      4.
      [`manifests-singleton.ts:385`](packages/next/src/server/app-render/manifests-singleton.ts#L385)
      resolves the action using:
      
         ```ts
         workers[normalizeWorkerPageName(workStore.page)]
         ```
      
         The keys therefore differ:
      
         ```text
         Looked up: app/static-params/[slug]
         Actual:    app/(group)/static-params/[slug]/page
         ```
      
      The missing worker entry throws “Failed to find Server Action” at line
      398.
      3dfe55b5
    • Tobias Koppers's avatar
      fix(codemod): find bundled docs via workspace packages in agents-md (#100017) · 43cb38c7
      Tobias Koppers authored
      ### What?
      
      When `npx @next/codemod agents-md` runs from the root of a monorepo with
      isolated installs (pnpm), it now uses the docs bundled in a workspace
      package's `next` install. Before, it downloaded a second copy into
      `.next-docs` and edited `.gitignore`. Part 2 of 2 for #99771, stacked on
      #100016.
      
      Example: from a pnpm root where only `apps/web` depends on
      `next@16.4.0`, it now writes `root:
      ./apps/web/node_modules/next/dist/docs` and logs:
      
      ```
      Using the docs bundled with Next.js 16.4.0 from workspace package apps/web at ./apps/web/node_modules/next/dist/docs (no download needed).
      ```
      
      ### Why?
      
      `getNextjsVersion` already falls back to scanning workspace packages, so
      the version was detected (16.4.0). But `getBundledDocsInfo` only
      resolved `next` from the cwd. Under pnpm, `next` isn't resolvable from
      the root, so the codemod fell through to downloading.
      
      ### How?
      
      `getBundledDocsInfo(cwd, version)` now takes the requested version:
      - It uses the install resolved from the cwd if that install's version
      matches.
      - Otherwise it walks the workspace packages with the same
      `detectWorkspace` and `expandWorkspacePatterns` discovery
      `getNextjsVersion` uses, and returns the **first package in workspace
      order** whose bundled docs match that version.
      - When nothing matches, the existing download path is unchanged.
      
      The CLI logs which workspace package it picked.
      
      ### Verification
      
      New offline e2e tests:
      - A pnpm root uses the bundled docs: no download, no `.gitignore`.
      - With several versions and no `--version`, the highest (detected)
      version's package is indexed.
      - With duplicate matches, the first in workspace order is used and
      logged (patterns are listed in non-alphabetical order).
      - A matching install resolved from the cwd wins.
      - `--version` selects a workspace package even when the cwd resolves
      another version.
      - With no match, it still downloads.
      
      Results:
      - The full agents-md e2e suite passes: 28/28, also with `FORCE_COLOR=1`.
      - Manually reproduced the issue's step 3 against a simulated pnpm
      workspace: it now uses the bundled docs.
      
      Fixes #99771
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet c69f306a-7676-4b84-8d3a-927ca1ab5f43 -->
      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>
      43cb38c7
    • Tobias Koppers's avatar
      fix(codemod): make agents-md docs root relative to the output file (#100016) · 8a63e04f
      Tobias Koppers authored
      ### What?
      
      `npx @next/codemod agents-md` now writes every path in the generated
      docs index relative to the directory of the `--output` file, not the
      current working directory. Part 1 of 2 for #99771; the stacked follow-up
      handles running from a monorepo root.
      
      - **`root`**:
      - **Bundled docs:** links the install that was actually indexed, through
      its stable `node_modules/next` symlink path, relative to the output
      file. Example: running from `apps/web` with `--output ../../AGENTS.md`
      now writes `root: ./apps/web/node_modules/next/dist/docs` instead of a
      broken `./node_modules/next/dist/docs`.
      - **Downloaded docs:** `.next-docs` is linked the same way
      (`./apps/web/.next-docs`).
      - **Regeneration hint**: now `run this command from this file's
      directory: … --output AGENTS.md`. It used to embed the raw cwd-relative
      `--output ../../AGENTS.md`.
      - **Absolute `--output`**: now resolved with `path.resolve`. Previously
      `path.join` appended it to the cwd.
      - **Prefixes**: links always start with `./` or `../`. The old
      `startsWith('.')` check would have emitted `.next-docs`.
      
      ### Why?
      
      Agents resolve `root` from the `AGENTS.md` file's location, the same
      convention as the `agentRules` block ("resolved from this file's
      directory"). Monorepos that keep a single root `AGENTS.md` had to run
      the codemod from the app, and that produced a `root` that doesn't exist
      from the repo root.
      
      Simply switching the base to the output directory isn't enough. The
      conventional-path shortcut would then check the output directory's
      `node_modules`. If the root hoists a different `next` (e.g. 16.3.0 while
      the app has 16.4.0), the link would point at a different version's docs
      than the one indexed. That case is covered by a test.
      
      ### How?
      
      - `getBundledDocsInfo` now returns `resolvedFrom`, the directory `next`
      was resolved from.
      - `getBundledDocsLinkPath(fromDir, docsPath, resolvedFrom)` prefers
      `<resolvedFrom>/node_modules/next/dist/docs`, but only if it is the same
      install. Otherwise it falls back to the realpath.
      - A new `getRelativeLinkPath` helper builds the `./`/`../`-prefixed,
      forward-slash link for both branches.
      - Paths are compared and related in canonical form
      (`fs.realpathSync.native`). On Windows, `process.cwd()` can keep an 8.3
      short name (`C:\Users\RUNNER~1\…`) while module resolution returns the
      long name; mixing the two produced a broken root. The parent directory
      is canonicalized before `node_modules/next/dist/docs` is appended, so
      the stable symlink path is kept.
      
      ### Verification
      
      - New offline e2e tests in `lib/__tests__/agents-md-e2e.test.js`, using
      a pnpm-style isolated fixture and a stubbed `pullDocs`:
        - output outside the cwd (bundled and downloaded);
        - mixed hoisted versions;
        - the hint;
        - absolute `--output`;
        - `./` and `../` boundaries;
      - a cwd spelled differently from the realpath: a symlinked alias, and a
      mock in which only the native realpath canonicalizes, as with Windows
      8.3 names. Both failed before the canonical-path change.
      - The existing agents-md e2e suite passes, including its network
      download tests: 22/22.
      - Manually reproduced both of the issue's scenarios against a simulated
      pnpm workspace:
        - Running from the app now writes a `root` that resolves.
      - Running from the root still downloads; the stacked follow-up fixes
      that.
      
      Part of #99771
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet c69f306a-7676-4b84-8d3a-927ca1ab5f43 -->
      
      ---------
      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>
      8a63e04f
    • Sebastian "Sebbie" Silbermann's avatar
      [cd] Support non-LTS releases (#99948) · f4d1b064
      Sebastian "Sebbie" Silbermann authored
      #99807 replaced versioned release branches with the fixed
      `releases/lts/active` + `releases/lts/maintenance` refs. This PR builds
      the complete story for releases that do not fit those two branches, in
      four parts:
      
      **1. Purely version-based LTS ref adjustment** (revises the routing
      merged in #99807)
      
      `updateLtsBranchRefs` no longer looks at `semverType` at all. After a
      stable release it compares only the released version
      (`readReleaseVersion()`) against npm, and it never matters which branch
      or tag the release was dispatched from:
      
      - released version starts a **new major** → `releases/lts/maintenance`
      takes `releases/lts/active`'s position, then `releases/lts/active` moves
      to the new tag
      - on the **latest published major** (npm `latest`) and newer than
      everything published in that line → `releases/lts/active` moves to the
      new tag
      - on the **previous major** and newer than everything published in that
      line → `releases/lts/maintenance` moves to the new tag
      - anything else (older versions, prerelease channels) → no refs move
      
      The "newer than everything published in that line" check resolves the
      caret range of the released version against npm (equivalent to `npm view
      next@^<version> version`), doubling as a no-rewind guard: an errant
      release cut on an old line (e.g. 15.5.0 while 15.7.x is published)
      cannot drag a branch backwards. This also fixes the gap the old
      patch-does-nothing rule had: releasing 16.5.0 from the
      `v16.5.0-canary.1` tag while canary sits at `16.5.0-canary.2` moves
      `active` as it should.
      
      **2. Tag-dispatched (detached HEAD) releases**
      
      Dispatching `Trigger Release` on a tag — e.g. cutting a stable version
      from an older canary tag — performs a tag-only release: the signed
      release commit lives only on the new tag and pushes no branch; the
      version-based rules above then move the LTS refs exactly as for any
      other dispatch. The tag push drives `build_and_deploy` as usual, and
      `sync_backport_canary_release` advances canary afterwards when the
      release is semver-ahead of it. (Dispatching on a tag runs the tag's own
      workflow and scripts, so this takes effect for tags cut after this
      lands; pre-existing `next-*` branches remain usable for older lines in
      the meantime.)
      
      **3. Zero-setup branches for changes based on older tags**
      
      A tag-only release cannot carry changes, so a fix for an older line
      (e.g. 15.4.x once 15.x has moved on) gets a branch. The name is
      functionally irrelevant — by convention we keep the old
      `next-<major>-<minor>` pattern — and any maintainer can create it with
      no workflow and no setup commit, because publishing is gated on
      bot-created tags, not on branches:
      
      ```bash
      git push origin v15.4.8^{commit}:refs/heads/next-15-4
      ```
      
      The `build_and_test.yml` / `build_and_deploy.yml` push filters include
      `next-*-*`, and the staging deploy-target condition globs
      `refs/heads/next-*-*`, so CI and the pre-publish build run on pushes
      automatically. Backport the fix, dispatch `Trigger Release` (stable,
      `patch`) on the branch, and the bot-created tag drives the publish; no
      LTS refs move since newer versions of that major are already published.
      
      **4. `scripts/release-branches.json` removed**
      
      Its only consumer was the `version-bump.js` branch gate
      (`assertBranchIsAllowed` / `--allow-branch`), which protected nothing
      the publish path doesn't already protect: tags are bot-only, real
      releases run through the workflow's app credentials, and the gate read
      per-branch content so it could never stop a determined actor. The gate,
      the flag, and the bypass call sites in `start-release.js` /
      `set-preview-version.js` are gone.
      
      Docs and the `backport-pr` skill describe the new model: LTS branches by
      default, a "Releases based on older tags" section covering both flows
      (branch + backport + dispatch for changes, tag dispatch for no-change
      one-shots).
      
      ## Verification
      
      All as `node ./scripts/start-release.js --release-type <t> --semver-type
      <s> --dry-run` (mock client, zero API calls):
      
      - attached **patch** (16.5.0 > npm latest 16.4.0) → `PATCH
      refs/heads/releases/lts/active` to the tag SHA
      - attached **minor** → same move; attached **major** → `maintenance`
      move (active's pre-move tip) before the `active` move
      - attached **canary** → zero LTS ref API calls
      - **detached** patch (the canary.1 scenario) → tag-only release (no
      branch PATCH from the release commit) **plus** the `releases/lts/active`
      move
      
      ---------
      Co-authored-by: 's avatarClaude Code <noreply@anthropic.com>
      f4d1b064
    • Aurora Scharff's avatar
      docs: link ensureStatic TypeScript hints to its API reference (#100033) · 52a822cf
      Aurora Scharff authored
      ## Summary
      
      The TypeScript language-service hints for the `ensureStatic` route
      segment config pointed at `(docs coming soon)`, so hovering the export
      in an editor gave no path to its API reference, which now exists. This
      points the hint at that page and states in the `'prefetch'` option hint
      that forcing a static prefetch stops runtime prefetch requests, while
      request-specific content behind `<Suspense>` still renders during
      navigation.
      
      Maintainer dashboard:
      https://next-maintainer-agent.vercel.tools/investigations/feedback/149
      DX Agent feedback:
      https://dxagent.labs.vercel.dev/dashboard/feedback/d98438c6-3ff3-4239-b5f9-5ccde3fe7b52
      
      ## Verification
      
      - `npx prettier --check
      packages/next/src/server/typescript/rules/config.ts`
      
      <!-- NEXT_JS_LLM -->
      
      Prepared in fork:
      https://github.com/vercel-labs/next.js-experimental/pull/256
      
      ---------
      Co-authored-by: 's avatarvercel-gh-bot-2[bot] <282331341+vercel-gh-bot-2[bot]@users.noreply.github.com>
      52a822cf