1. 14 Oct, 2026 21 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.11 · f5be3904
      next-js-bot[bot] authored
      f5be3904
    • next-js-bot[bot]'s avatar
    • dev's avatar
      docs: fix "a HTTP"/"a SSR" grammar and Node.js casing (#99542) · e1b13956
      dev authored
      Small docs fixes in the Pages Router docs:
      
      - `use-router.mdx`: `Node.JS` -> `Node.js`, and `a SSR` -> `an SSR`
      - `07-api-routes.mdx`: `a HTTP` -> `an HTTP` (heading and body)
      
      The heading anchor changes from `#sending-a-http-response` to
      `#sending-an-http-response`. I checked that nothing in `docs/` links to
      the old anchor.
      e1b13956
    • Joseph's avatar
      docs: narrow catchError ErrorInfo.error, typed as unknown (#100196) · 1193e82a
      Joseph authored
      ## Summary
      
      `ErrorInfo.error` from `next/error` is typed as `unknown`, but the
      `catchError` API reference listed it as `Error` and its examples, plus
      the one in Getting Started > Error Handling, read `error.message`
      directly, which fails `tsc`.
      
      - `errorInfo` tables (App and Pages): `error` type is now `unknown`,
      with a note to narrow before reading `message`.
      - All `catchError` examples narrow with `instanceof Error` before
      rendering the message, matching the `onRequestError` fix in #94518.
      
      <!-- NEXT_JS_LLM -->
      1193e82a
    • Aurora Scharff's avatar
      docs: update links for newly transferred demos (#100197) · aec29256
      Aurora Scharff authored
      ### What?
      
      Updates six documentation links to point to repositories that moved into
      the `nextjs` organization.
      
      ### Why?
      
      The old `vercel` and `vercel-labs` repository paths now redirect after
      the transfers. The canonical links should use their new locations
      directly.
      
      ### How?
      
      Replaces the repository URLs for the View Transitions, Public Static
      Pages, Nextgram, and On-Demand ISR demos.
      
      Validated the changed files with Prettier and `git diff --check`.
      aec29256
    • Aurora Scharff's avatar
      ci: update release eval workflow pin (#100189) · 3f1086bd
      Aurora Scharff authored
      ## Summary
      
      Update the release-eval reusable workflow pin to the OIDC authentication
      fixes in vercel/next-evals-oss#137 and #138. Pass Vercel's public OAuth
      client ID from a non-secret GitHub Actions variable so credential-shaped
      configuration is not committed to source.
      
      The first manual `16.4.0` run stopped before starting any evals because
      a public Next.js runner could not load an internal action. The updated
      workflow performs the same short-lived exchange inside its existing
      authentication helper.
      
      ## Verification
      
      - `git diff --check`
      - No Next.js build run (workflow pin only)
      
      <!-- NEXT_JS_LLM -->
      3f1086bd
    • Niklas Mischkulnig's avatar
      Remove staticInfo.rsc (#100172) · 60a9a3d2
      Niklas Mischkulnig authored
      It’s safe because .rsc wasn’t actually detecting client pages:
      - It searched for the compiler-generated marker
      `__next_internal_client_entry_do_not_use__`, not "use client".
      Static-info analysis reads raw source, so normal pages returned
      `'server'` or `undefined`.
      - Both values behaved identically: callers checked `rsc !== 'client'`,
      making the result effectively just “is this an App Router entry?”
      - Client-entry skipping was already redundant: it checked
      `isServerComponent || isInsideAppDir`.
      - The build’s remaining SSG branch was unreachable: it checked
      `isServerComponent` inside the Pages Router branch, where it was always
      false.
      The cleanup replaces those ineffective checks with the router
      classification they already represented. Actual client/server boundaries
      are still determined by the bundler; its RSC metadata is untouched.
      Build, type checks, unit tests, and focused Webpack dev/production tests
      passed.
      60a9a3d2
    • Will Binns-Smith's avatar
      fix(analyze): use route summaries as the analyzer route index (#100081) · a8b3bf15
      Will Binns-Smith authored
      ### What?
      
      The bundle analyzer now uses the `route-summaries.json` that Turbopack
      writes as its **only** route index. This covers `next analyze`, `next
      build --analyze`, `next analyze export`, the analyzer UI's route picker,
      and comparison views. `routes.json` is no longer written or read, and
      `/_global-error` is listed like any other route.
      
      ### Why?
      
      `next analyze export` failed with ENOENT on metadata routes that use
      `generateImageMetadata` or `generateSitemaps`, and the analyzer UI
      couldn't load their data either.
      
      The cause was two route indexes that disagreed:
      
      - Turbopack writes each route's `analyze.data` under its structural
      entrypoint key, e.g. `/icon` or `/sitemap.xml`. It also lists those keys
      in `route-summaries.json`, along with each route's sizes.
      - `routes.json` was built separately from the routes manifest, which has
      the generator-adjusted pages `/icon/[__metadata_id__]` and
      `/sitemap/[__metadata_id__]`.
      
      Readers turn each listed route straight into `<route>/analyze.data`, so
      they asked for files that were never written.
      
      Since `route-summaries.json` already has every route plus its sizes, a
      second index is redundant. Dropping it makes the route list and the data
      on disk agree by construction.
      
      ### How?
      
      - **Capture:** both capture commands read and validate the summaries,
      then use that list for the snapshot's `routeCount`. Nothing is filtered,
      so `/_global-error` (which can be large) is now visible.
      - **Export:** `next analyze export` uses the same validated list, with
      the same `--route` filtering. If `route-summaries.json` is missing (some
      16.4 canary snapshots predate it), the command fails with a clear
      message to re-run `next analyze`, without writing partial output.
      - **UI:**
      - A shared helper derives each build's route list from its own
      summaries, for the current build, the baseline, and the route picker.
      - The comparison strip counts routes from the summaries rather than the
      `routeCount` saved in older snapshot metadata, which didn't include
      `/_global-error`.
      
      **Compatibility:** older snapshots that have route summaries keep
      working. Snapshots captured while this bug was present export and
      compare correctly without re-capturing, because their summaries already
      use the structural names. Their stale `routes.json` is ignored.
      
      ### Tests
      
      The `test/e2e/next-analyze` fixture now has a nested
      `generateImageMetadata` icon and a `generateSitemaps` sitemap. The suite
      checks, for both `next analyze` and `next build --analyze`, that:
      
      - the summary route set, including `/_global-error`, has `analyze.data`
      for every route;
      - exports emit exactly those routes;
      - `routeCount` matches the summaries;
      - `routes.json` is not written.
      
      It also checks that a stale legacy `routes.json` is ignored, and that a
      snapshot without summaries fails with the re-capture message. I also
      exported a snapshot captured by the buggy published canary with the
      locally built CLI: it now exports `/icon` without re-capturing.
      
      Fixes #99970
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet dc2bf147-ed0d-4cfa-88c7-2b3b824b11a7 -->
      
      ---------
      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>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      a8b3bf15
    • Will Binns-Smith's avatar
      Reload on missed Turbopack startup CSS updates (#99963) · f66360c7
      Will Binns-Smith authored
      ### What?
      
      Recover missed Turbopack startup CSS edits with a full page reload,
      while keeping ordinary CSS HMR state-preserving. Related: #99893; reuses
      the version-mismatch recovery introduced in #97966.
      
      ### Why?
      
      CSS can finish loading before the browser starts HMR. An edit in that
      window leaves old CSS in the page, but initializing the browser from the
      current WebSocket version hides the mismatch. The initial HTML needs to
      carry the version it actually rendered, and the server must observe CSS
      before any browser subscribes.
      
      ### How?
      
      - Capture the client HMR version before rendering and emit
      `__nextHmrInitialVersion` in an inline script **only in dev-server HTML
      with Turbopack HMR**, using safe serialization, the existing CSP nonce
      and Pages crossOrigin precedence.
      - Use the HTML version as the first-connection fallback. Previously
      observed WebSocket versions retain priority on reconnect. A stale
      subscription reuses the existing reload message/handler.
      - Await CSS-inclusive observation before serving HTML: App route client
      output, Pages route client output, and Pages' global `_app` client
      output. Pages chunks exclude dependencies already provided by `_app`, so
      the global observer is necessary for a truly fresh Pages-first load.
      - Reuse existing subscription ownership/deduplication and per-cycle
      client-version accounting. Successful observation sends no
      refresh/build-success message and does not invalidate the
      server-component cache. Subscriptions remain disabled for one-shot
      compilation. A genuinely missed startup JS output change can use the
      same recovery path.
      - Remove the previous startup stylesheet reconciliation/readiness
      machinery and restore the original CSS loader. Remove Pages' duplicate
      reload action; its existing guarded hot-middleware listener already
      handles the message before and after hydration.
      
      ### Verification
      
      Final local runs use isolated packages:
      
      - **Turbopack: 26 passed** — repeated App → Pages → App startup races,
      independent fresh Pages-only startup recovery, controlled delayed Pages
      greeting delivery, no-edit controls, global `_app`
      JS/CSS-dependency/error/config recovery, and all app-document rendering
      tests.
      - **Cache Components: 14 passed** — both startup/lifecycle fixtures.
      - **Pages/MCP regressions: 41 passed, 10 snapshots** — full/hot reload,
      error pages, syntax/runtime recovery and compile_route.
      - **Webpack: 30 passed, 10 snapshots**; **production/start: 12 passed**.
      Twelve local dev-Turbopack HMR cases are appropriately gated in those
      modes; both unconditional HTML-absence assertions still run.
      - **14 units passed**, including await-before-HTML, dedicated global
      key, absent/dev-disabled hooks, setup rejection and cleanup-key
      semantics.
      - Full bootstrap, root/Next/runtime types, ESLint, Prettier and
      whitespace checks passed. No snapshots changed.
      
      Pre-fix isolated tests reproduced the missing crossOrigin and fresh
      Pages-first `HTML 0 / greeting 0` failures. Tests now await actual first
      greeting/subscription evidence rather than treating hydration or
      socket-open as message readiness. They still require a newer first
      greeting, the original HTML subscription version, exactly one recovery
      navigation, current CSS, ordinary CSS state preservation and a real
      reconnect. Each race browser closes before file restoration so it cannot
      mask later startup detection.
      
      Coverage limits: controlled delayed delivery is proven for Pages, not
      App. Live custom/default `_app` endpoint-identity add/remove and native
      subscription counts were not instrumented; code/dependency changes,
      config replacement and cleanup-key semantics are covered. Switching
      between distinct global CSS imports already produces competing reloads
      with or without the new observer; that pre-existing behavior is a
      separate follow-up, not ordinary same-file CSS HMR. Local browser runs
      used Chromium. Native/runtime source is unchanged in this follow-up;
      four earlier local **dev-profile** Rust snapshots are historical
      evidence, not a new release-with-assertions run. No agent CI reruns were
      performed, and local verification does not claim remote CI success.
      
      <!-- NEXT_JS_LLM -->
      <!-- fleet 12f26da0-c82d-4bee-b78c-c8151440ae25 -->
      
      ---------
      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>
      Co-authored-by: 's avatarLuke Sandberg <lukesandberg@users.noreply.github.com>
      f66360c7
    • Aurora Scharff's avatar
      ci: run evals for releases and canaries (#100126) · 2df613db
      Aurora Scharff authored
      ## What?
      
      Run the reusable `vercel/next-evals-oss` workflow after a stable Next.js
      package publishes successfully. The caller provides the exact version,
      tag, commit SHA, release/backport classification, and source workflow
      URL.
      
      The workflow distinguishes a normal release from a backport by pairing
      the successful tag run with the `build-and-deploy` branch run for the
      same SHA. Manual dispatch accepts exact stable, backport, and
      `X.Y.Z-canary.N` targets, so previous patches and published canaries can
      be measured on demand.
      
      ## Why?
      
      This starts the standalone pass@1 automation in
      https://github.com/vercel/next-evals-oss/pull/134. It runs the tier-one
      Base and AGENTS.md matrix against the exact published package, retries
      discarded infrastructure failures, records non-scoring confirmation
      attempts for genuine failures, and sends Eve the Slack report.
      
      The public benchmark keeps its existing pass@4 methodology. The
      automation opens a draft PR under `measurements/releases/` containing
      sanitized aggregate data and the complete scored and confirmation output
      for review. The measurement remains separate from the publishable
      top-level `results/` tree and `agent-results.json`, so merging it cannot
      update `nextjs.org/evals`.
      
      The caller grants `contents: read` and `id-token: write`, passes the
      non-secret Vercel project identifiers and Eve endpoint, and forwards the
      existing Next.js release GitHub App client ID and private key to the
      reusable workflow. The App credential is used only by the final
      reporting job to open the draft measurement PR. Model jobs receive
      short-lived Vercel OIDC credentials, plus the existing Cursor key only
      for Cursor runs.
      
      Automatic triggers remain limited to stable releases and backports.
      Canary measurements run only when someone starts them from GitHub
      Actions with an exact published version, matching tag, and full commit
      SHA.
      
      The reusable workflow landed in
      https://github.com/vercel/next-evals-oss/pull/134 and this caller is
      pinned to its commit on `main`.
      
      ## Verification
      
      - Checked the workflow with the repository's Prettier configuration
      - Checked release/backport classification against real workflow pairs:
      `v16.4.0` / `canary` and `v16.3.8` / `next-16-3`
      - Pinned the reusable workflow to merged `next-evals-oss/main` commit
      `dc9406f40a0e4c7cf14e8531fe54517605511b53`
      - `git diff --check`
      - Not run: `pnpm build-all` (CI workflow-only change)
      
      <!-- NEXT_JS_LLM -->
      2df613db
    • Niklas Mischkulnig's avatar
      test: speed up use-cache-cross-deployment even more (#100181) · 9ec56531
      Niklas Mischkulnig authored
      Get rid of a few more unnecessary rebuilds
      9ec56531
    • Niklas Mischkulnig's avatar
      Remove unused getParams matcher cache (#100078) · 9c70ede1
      Niklas Mischkulnig authored
      `last` was never getting assigned, so there was never a cache hit.
      
      Even if it was implemented correctly, the benefits are questionable as a
      LRU of size 1 isn't awfully effective anyway.
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      9c70ede1
    • Tobias Koppers's avatar
      Turbopack: only search <head> for existing chunk tags (#100175) · cad19c28
      Tobias Koppers authored
      ### What?
      
      Turbopack's browser runtime now looks for existing chunk tags in
      `<head>` only, and `turbopack-dev-server` puts its chunk scripts into
      `<head>` as `<script async>` instead of at the end of `<body>`.
      
      Follow-up to #100047, answering [this review
      comment](https://github.com/vercel/next.js/pull/100047#discussion_r4267298397).
      
      ### Why?
      
      #100047 removed the document-wide `querySelectorAll` from the chunk-tag
      lookup, but the lookup still iterated every `<script>`/`<link>` in the
      document, so its cost grew with the page content.
      
      I checked where chunk tags actually land in Next.js (Chromium; hard
      loads, App Router soft navigation, Pages Router, Suspense streaming,
      `loading.tsx`, PPR in prod):
      - The tags the runtime looks up are all in `<head>`.
      - The tags in `<body>` are the bootstrap `<script>` (a runtime chunk,
      never looked up), late `<link rel=preload>` tags for `next/dynamic`
      chunks in streamed boundaries, and, under PPR, a second copy of the
      `noModule` polyfills script.
      
      `turbopack-dev-server` was the one producer that put chunk scripts into
      `<body>`.
      
      Synthetic Chromium microbenchmark of the compiled lookup helper, 80
      lookups, ms (before → after):
      
      | CPU | Body elements | Before | After |
      |---|---|---|---|
      | 1× | 800 | 3.5 | 2.6 |
      | 1× | 8,000 | 8.1 | 2.5 |
      | 1× | 32,000 | 23.3 | 2.5 |
      | 4× | 800 | 14.4 | 10.8 |
      | 4× | 8,000 | 33.9 | 10.5 |
      | 4× | 32,000 | 108.1 | 10.9 |
      
      ### How?
      
      - **Runtime** (`runtime-backend-dom.ts`): `findChunkScripts` /
      `findChunkLinks` iterate `document.head.getElementsByTagName(...)`.
      Matching is unchanged (exact URL, `?query` suffix, decoded variant,
      `rel` filter). This applies to chunk loads, CSS reloads and dev HMR
      unloads. Tags in `<body>` are deliberately ignored:
        - a chunk whose tag is only in `<body>` gets a new tag in `<head>`;
      - HMR unload leaves `<body>` copies, such as streamed `rel=preload`
      links, in place.
      - **Dev server** (`html.rs`): the HTML is rendered by a small pure
      function. Stylesheets come first, then the chunk scripts as `<script
      async>`, all in `<head>`; the page body stays in `<body>`. The runtime
      doesn't depend on chunk execution order. Entry code may now run before
      `<body>` is parsed, so it has to wait for the DOM itself if it touches
      it.
      - **Tests**:
        - `dynamic-chunk-dedupe` gains:
      - a streamed `next/dynamic` route that asserts each chunk is requested
      once and no tags are duplicated;
      - a Turbopack-only on-demand case, where inert copies of the chunk's
      tags in `<body>` must be ignored (it fails on the old lookup);
      - a Turbopack dev case where HMR unload removes only the `<head>` tags
      (it also fails on the old lookup).
        - The Rust unit tests cover the new dev-server HTML.
      - **Snapshots** for the files that inline the DOM runtime are
      regenerated.
      
      Verified locally:
      - `dynamic-chunk-dedupe` in Turbopack start, dev and cache components,
      plus webpack start, where the Turbopack-only cases are skipped;
      - `chunk-load-failure`, and the CSS and dynamic HMR suites;
      - `cargo test -p turbopack-dev-server` and the snapshot tests;
      - a `turbopack-cli dev` smoke test with a dynamic import and CSS.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 00169b97-050c-43e3-a74e-5c9141d0996e -->
      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>
      cad19c28
    • Darpan Kakadia's avatar
      fix: mark HTTP fetch failures as span errors (#99877) · 74c6c1b6
      Darpan Kakadia authored
      ## Problem
      
      Fetch spans report HTTP failures without an error status.
      
      ## Solution
      
      Mark recorded responses with status >= 400 as errors. Preserve response
      bodies and streaming.
      
      <!-- NEXT_JS_LLM -->
      74c6c1b6
    • Aurora Scharff's avatar
      docs: explain router.prefetch stages (#99786) · 93cec91d
      Aurora Scharff authored
      ## Summary
      
      - clarify that `router.prefetch()` defaults to the App Shell under
      Partial Prefetching and document `kind: 'full'` for the per-link stage
      - expose the existing `auto` and `full` values through the public
      TypeScript options and preserve the options with typed routes
      - reformat the `useRouter` method reference for narrow screens without
      changing its existing descriptions
      
      Addresses [Agent Feedback finding
      1455](https://next-maintainer-agent.vercel.tools/agent-feedback/1455).
      Related to #62692.
      
      ## Verification
      
      - `pnpm exec eslint --config eslint.config.mjs
      packages/next/src/client/components/prefetch.ts
      packages/next/src/server/lib/router-utils/typegen.ts
      packages/next/src/shared/lib/app-router-context.shared-runtime.ts
      test/production/app-types/src/app/type-checks/router/page.tsx`
      - `pnpm prettier --with-node-modules --ignore-path .prettierignore
      --check <changed files>`
      - Not run: `pnpm --filter=next types` (the isolated worktree is missing
      package-local dependencies and reports unrelated missing-module errors)
      
      <!-- NEXT_JS_LLM -->
      93cec91d
    • Joseph's avatar
      docs: clarify Server Action dispatch across Mutating Data and the guide (#100144) · 36f5ed3b
      Joseph authored
      ## Summary
      
      The Server Actions guide describes one-at-a-time dispatch as a property
      of the client dispatcher, while Mutating Data called it an
      implementation detail that may change. Mutating Data now states the
      behavior and links to the guide section, so there is one canonical
      statement. The guide's note also says explicitly that the server does
      not queue Server Actions.
      
      - `fd925c90e80` docs: clarify Server Action dispatch across Mutating
      Data and the guide
      
      <!-- NEXT_JS_LLM -->
      36f5ed3b
    • Niklas Mischkulnig's avatar
      test: speed up use-cache-cross-deployment (#100138) · 8521c6ae
      Niklas Mischkulnig authored
      Don't run `next.build()` quite as often.
      
      This was the lowest hanging fruit. There will probably be another PR to
      improve it further
      8521c6ae
    • Tobias Koppers's avatar
      Turbopack: avoid document-wide selector scans when probing for chunk tags (#100047) · 2251f438
      Tobias Koppers authored
      ## Summary
      
      Fixes #99993.
      
      On the first non-runtime load of each chunk URL, Turbopack's browser DOM
      runtime checks whether a matching `<script>` or `<link rel=stylesheet>`
      already exists. That check was a document-wide `querySelectorAll` with
      four attribute and prefix selectors, so its cost grew with the size of
      the whole DOM. It runs on the main thread during hydration, roughly once
      per chunk. The selectors were also built by interpolating the URL
      without escaping: a decoded `"` threw a `SyntaxError`, and a `\` missed
      a tag that was already present.
      
      The production loader (`doLoadChunk`) and the dev backend (`unloadChunk`
      / `reloadChunk`) now look tags up with `getElementsByTagName` and plain
      string comparison. The helpers are defined once in the DOM backend and
      reused by the dev backend, since the runtime files are concatenated
      rather than imported as modules.
      
      Matching behavior is otherwise unchanged:
      - A tag matches if its raw attribute equals the chunk URL, or starts
      with the URL plus `?`, for both the URL and its `decodeURI` form. A
      different query string still does not match.
      - The stylesheet lookup still requires `rel` to be exactly `stylesheet`
      (ASCII case-insensitive). Dev CSS unload still ignores `rel`.
      - All matching tags are returned in document order, from both head and
      body.
      - Results are snapshot arrays, so removing tags while looping over them
      is safe.
      
      This lowers the cost per probe but is still proportional to the number
      of elements. A URL index that would make it independent of DOM size is
      out of scope here.
      
      ## Verification
      
      - New e2e test `test/e2e/app-dir/dynamic-chunk-dedupe`, passing with
      `pnpm test-start-turbo` and `pnpm test-dev-turbo`:
      - The fixture has server-rendered and `ssr: false` dynamic components,
      including CSS modules, and sets a `deploymentId` so chunk URLs carry
      `?dpl=`.
      - It asserts that styles apply, there are no page errors, each chunk is
      requested once, and the DOM has no duplicate chunk tags.
      - Sanity check: with the lookup deliberately broken, the DOM check
      failed on duplicate scripts and a duplicate stylesheet.
      - `pnpm test-start-turbo
      test/production/chunk-load-failure/chunk-load-failure.test.ts` (retry
      path): 3/3
      - `pnpm test-dev-turbo test/development/css-hmr-unmounted-chunk
      test/development/app-dir/hmr-dynamic-component`: 7/7
      - Snapshots regenerated with `UPDATE=1 cargo test -p turbopack-tests
      --test snapshot`. Only the runtime change appears in the diff, and
      132/132 pass on rerun.
      - A Chromium harness compared the old selectors with the new lookups on
      36 JS/CSS/unload cases. Results are identical except the `"` and `\`
      cases, which now match literally.
      - Sampled CPU profile on the issue's reproduction app at 4x CPU
      throttling (median of 5): probe time drops from 106.9 to 40.8 ms at
      about 4.3k elements, and from 215.9 to 51.6 ms at about 8.3k elements.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 00169b97-050c-43e3-a74e-5c9141d0996e -->
      
      ---------
      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>
      2251f438
    • Luke Sandberg's avatar
      Don't optimize the aggregation graph during `connect_child` (#100147) · 0fc57c31
      Luke Sandberg authored
      If a task completion enqueues too much optimization work we record an
      `optimization_pending` flag so that it can be processed in a later
      attempt.
      
      However `connect_child` calls `increase_active_count` which attempted to
      flush pending optimizations. This could greatly slow down execution by
      enqueueing graph management in the hot `connect_child` path. But also it
      could be self defeating, since we would optimize a task, and then add it
      as a child, which would (on task_completion) potentially add a new
      `upper` which could trigger more optimizations.
      
      For `Module::ident` this could be pathological since a lot of large
      tasks call it for all modules (e.g. to compute module ids), each of
      these could enqueue optimization work and then the next task (e.g. parts
      of asset tracing) could both complete optimizations and enqueue new
      ones.
      
      This severely punished `project_feature_usage` which was single threaded
      and thus did a lot of expensive work.
      0fc57c31
    • Luke Sandberg's avatar
      Simplify aggregation update queue control flow (#100146) · 6f6ea204
      Luke Sandberg authored
      Now that we are no longer suspending we can simplify control flow and
      implementation of the AggregationUpdateQueue
      
      * drop an unneeded `Clone` derive
      * process batch tasks via loops instead of `pop` + `push_front`
      * when we run out of optimization quota just immediately tag everything
      instead of popping each task and checking the quote again
      * simplify the public apis
      6f6ea204
    • Tobias Koppers's avatar
      [ci] Fix Rspack test manifest update workflow (#100052) · 179eba81
      Tobias Koppers authored
      ### What?
      
      Fixes the scheduled `Update Rspack test manifest` workflow. Both of its
      jobs, development and production, have failed every day, for example
      [run
      38217690831](https://github.com/vercel/next.js/actions/runs/38217690831).
      
      ### Why?
      
      The workflow is supposed to keep
      `test/rspack-{dev,build}-tests-manifest.json` up to date. Because it
      keeps failing, those manifests are stale, and the release Rspack shards
      run tests that are already known to fail (#100001 works around this by
      hand).
      
      There are two independent blockers:
      
      1. **The GitHub CLI has no token.** #93455 moved these workflows to the
      release GitHub App token, which is passed as `RELEASE_GITHUB_TOKEN`.
      That removed the env var the GitHub CLI used to pick up.
      `test/update-bundler-manifest.js` lists and downloads test-result
      artifacts with `gh api`, so those calls now fail with "set the GH_TOKEN
      environment variable".
      2. **The runner path is out of date.** The updater strips a hardcoded
      self-hosted runner prefix (`/root/actions-runner/...`) from test file
      paths. Current artifacts come from GitHub-hosted runners
      (`/home/runner/work/next.js/next.js/`). So even with auth fixed, the
      script stops while processing the results.
      
      ### How?
      
      - **Separate tokens for reads and writes.** The updater step now gets
      the job's built-in token for the GitHub CLI, used only to read
      artifacts. The release App token is unchanged and still does the work
      that has to trigger CI: checkout, signed commits and PR creation. Its
      permissions are not widened.
      - **Least privilege.** Following `.github/AGENTS.md`, the workflow
      defaults to no permissions, and each job grants only `actions: read`.
      - **Path from the runner.** The updater derives its path prefix from
      `GITHUB_WORKSPACE`, with a trailing separator so manifest keys stay
      repo-relative (`test/...`). It assumes the jobs that produce and consume
      the artifacts run on the same kind of GitHub-hosted runner, which is
      true today. If the variable is missing it fails with a clear message, so
      a manual run can't produce bad keys.
      
      This follows the approach of @bgw's earlier draft #94835, applied fresh
      on current canary. The obsolete Turbopack workflow that #94835 deleted
      is already gone.
      
      ### Verification
      
      - On unmodified canary, the updater downloads the artifact and then
      fails on the old runner prefix.
      - With this change, the dev and build updaters both succeed against the
      latest real canary artifacts. All 1,535 dev keys and 1,606 build keys
      are repo-relative. I discarded the generated manifests.
      - Workflow permissions and token wiring were checked by parsing the
      YAML. The updater's path handling was checked with zero, one and several
      trailing slashes, and with the variable missing.
      - Prettier and ESLint pass.
      - **Not yet verified end to end in Actions.** Local runs used my own
      GitHub CLI login, not the job-scoped token. Please dispatch the workflow
      on this branch, or wait for the next scheduled run, to confirm `actions:
      read` is enough. The first successful run will open a large manifest
      refresh PR. Because the workflow uses `--override`, previously-passing
      tests can move to failing in that refresh.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 96f9352a-face-45ea-8233-1f0245d272b9 -->
      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>
      179eba81
  2. 13 Oct, 2026 19 commits
    • HiiTea's avatar
      docs: fix example path regexr (#100084) · 6cc25f4f
      HiiTea authored
      6cc25f4f
    • 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