1. 23 Oct, 2026 3 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.25 · faa474c4
      next-js-bot[bot] authored
      faa474c4
    • Niklas Mischkulnig's avatar
    • Will Binns-Smith's avatar
      Cache bundle analysis per output file (#100475) · ba182aa1
      Will Binns-Smith authored
      ## Summary
      
      Analyze each emitted and traced file once in a cached task that returns
      its filename, chunk membership, and chunk parts with normalized sources
      and compressed sizes. Routes previously made 3–5 task calls per shared
      file, and task-graph bookkeeping for those calls dominated analysis.
      Splitting, compression, and membership enumeration run as plain helpers
      under that task, since each is read once.
      
      Measured on v0/chat with `next build --analyze` (#99962), analysis phase
      only: new tasks went from 269k to 242k, calls into existing tasks from
      8.49M to 5.07M, and median CPU time from 150s to 124s. All 455 data
      artifacts were byte-identical across 12 runs.
      
      Supersedes #100486.
      
      ## Verification
      
      - `cargo test -p turbopack-analyze --test split_chunk` and `cargo test
      -p next-api --lib analyze` passed.
      - Rebuilt the native binding with `release-with-debug`, installed it in
      v0/chat, and compared `next build --analyze` output against the previous
      binary across alternating runs.
      
      <!-- NEXT_JS_LLM -->
      ba182aa1
  2. 22 Oct, 2026 31 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.24 · 62e889a5
      next-js-bot[bot] authored
      62e889a5
    • Niklas Mischkulnig's avatar
      fix(turbopack): evaluate pure constructor callees (#100588) · 10cdcda5
      Niklas Mischkulnig authored
      ## Summary
      
      Preserve effects from evaluating a constructor callee even when
      construction is PURE-annotated. For example, `/*#__PURE__*/ new
      (getConstructor())()` must account for calling `getConstructor()`.
      
      Visit the callee before arguments, matching pure call handling. Add
      analyzer and execution regressions while preserving upstream PURE
      callback handling from #100577.
      
      Independent of the callback stack (#100586 / #100587); rebase whichever
      lands later if their `Expr::New` edits overlap.
      
      ## Verification
      
      - Full `turbopack-ecmascript` library: 609 tests passed.
      - Constructor-callee execution regression passed.
      - Rustfmt and diff checks passed. Full monorepo suite not run locally.
      
      <!-- NEXT_JS_LLM -->
      
      <!-- fleet 87a54898-52c9-4506-ae11-7f75f7e661f6 -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      10cdcda5
    • Jimmy Miller's avatar
      Add webpack utils (#99826) · e828f1e5
      Jimmy Miller authored
      Okay, so for these hashes the way it works in webpack is they have an
      assembly script implementation that they then go and compile to wasm and
      embed that wasma as a base64 encoded string.
      
      I felt introducing wasm was a bit overkill. My first thought was doing
      this with rust. But even giving it the best possible chance of winning
      (using workers vs processes) it doesn't win on these smaller cases. It
      does on the larger ones.
      
      Judging all of this, I thought the easiest answer is to just do some
      iterations with an agent on making these as fast as I could in js.
      
      Agents are quite good at algorithms like this. I did do some random
      testing of a ton of inputs and everything matches up. The speed reults
      are still a mixed bag.
      
      | Workload | JS | WASM | Integrated Rust | Rust vs JS | JS vs WASM |
      | ------------------------------ | -------: | -------: | --------------:
      | ----------- | ----------- |
      | CSS MD4, 100 classes ×2 | 57 µs | 50 µs | 398 µs | 7.0× slower | 1.1×
      slower |
      | CSS xxhash64, 100 classes ×2 | 86 µs | 48 µs | 439 µs | 5.1× slower |
      1.8× slower |
      | CSS MD4, 1,000 classes ×2 | 584 µs | 516 µs | 3,572 µs | 6.1× slower |
      1.1× slower |
      | CSS xxhash64, 1,000 classes ×2 | 792 µs | 459 µs | 2,445 µs | 3.1×
      slower | 1.7× slower |
      | Babel MD4, 64 KiB | 108 µs | 70 µs | 65 µs | 1.7× faster | 1.5× slower
      |
      | Babel MD4, 1 MiB | 1,582 µs | 1,090 µs | 974 µs | 1.6× faster | 1.5×
      slower |
      | Babel xxhash64, 64 KiB | 41 µs | 4.4 µs | 19 µs | 2.2× faster | 9.3×
      slower |
      | Babel xxhash64, 1 MiB | 642 µs | 68 µs | 249 µs | 2.6× faster | 9.4×
      slower |
      
      Wasm is the winner. But I just wasn't sure it was really by enough to go
      add that complexity. The js keeps this as simple as we can get.
      
      Considering this hasn't been implemented earlier, I doubt this is super
      crucial, but we can always revisit if needed.
      
      Here are two uses of this functionality as described by the clanker
      
      > CSS Modules (css-loader): hashes the file path and local class name to
      generate scoped class names. This means many tiny hashes—roughly one per
      selector occurrence, sometimes more for longer generated names. It does
      not hash the whole stylesheet.
      > Babel (babel-loader): with disk caching enabled, hashes the source,
      options, and cache identifier to choose a cache filename. Usually one
      source-sized hash per file; no hashing when disk caching is disabled.
      
      I am adding this for completeness. But I think many uses of it (css
      modules for example) are going to be things we recommend native
      replacements for.
      
      <!-- Thanks for opening a PR! Your contribution is much appreciated.
      To make sure your PR is handled as smoothly as possible we request that
      you follow the checklist sections below.
      Choose the right checklist for the change(s) that you're making:
      
      ## For Contributors
      
      We encourage you to use AI to assist you in researching, creating, and
      reviewing changes. However, you must review and deeply understand the
      contributions you are making. For this reason, **pull request
      descriptions from external contributors must be written by a human**.
      
      ### Improving Documentation
      
      - Run `pnpm prettier-fix` to fix formatting issues before opening the
      PR.
      - Read the Docs Contribution Guide to ensure your contribution follows
      the docs guidelines:
      https://nextjs.org/docs/community/contribution-guide
      
      ### Fixing a bug
      
      - Related issues linked using `fixes #number`
      - Tests added. See:
      https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Adding a feature
      
      - Implements an existing feature request or RFC. Make sure the feature
      request has been accepted for implementation before opening a PR. (A
      discussion must be opened, see
      https://github.com/vercel/next.js/discussions/new?category=ideas)
      - Related issues/discussions are linked using `fixes #number`
      - e2e tests added
      (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
      - Documentation added
      - Telemetry added. In case of a feature if it's used or not.
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Signed commits
      
      - This repository requires verified commit signatures on protected
      branches.
      - If this pull request is blocked for unsigned commits, re-sign the
      commits and force-push the branch.
      - A `Signed-off-by` line in the commit message is not enough.
      
      ## For Maintainers
      
      - Minimal description (aim for explaining to someone not on the team to
      understand the PR)
      - When linking to a Slack thread, you might want to share details of the
      conclusion
      - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
      - Add review comments if necessary to explain to the reviewer the logic
      behind a change
      
      ### What?
      
      ### Why?
      
      ### How?
      
      Closes NEXT-
      Fixes #
      
      -->
      e828f1e5
    • Sebastian "Sebbie" Silbermann's avatar
      Cap bot user-agent matching at 1KB (#100604) · 7499b034
      Sebastian "Sebbie" Silbermann authored
      No known real UA string we're aware of exceeds ~500 bytes (uap-core:
      longest 492 B across 30,873 distinct strings; Matomo DeviceDetector:
      longest 482 B across 40,348), so oversized UAs are never bots we need to
      identify. This bounds regex work on attacker-controlled input as DoS
      defense-in-depth, mainly for user-configured `htmlLimitedBots` patterns
      which may be more expensive than the built-in one.
      
      A >1KB UA containing a bot token (e.g. `WhatsApp`) is now treated as a
      non-bot (streaming metadata served, `isBot()` false).
      
      Hosting providers likely already cap the `User-Agent` header (or any
      header value) e.g. [Vercel caps at
      16kb](https://vercel.com/docs/errors/request_header_too_large)
      
      <!-- NEXT_JS_LLM -->
      
      ---------
      Co-authored-by: 's avatarClaude Code <noreply@anthropic.com>
      7499b034
    • Sebastian "Sebbie" Silbermann's avatar
      Stop requiring build-all when bootstrapping a fresh clone or worktree (#100600) · 9ff761f2
      Sebastian "Sebbie" Silbermann authored
      The agent instructions required a full `pnpm build-all` (JS and Rust)
      after every worktree creation or branch switch. That is unnecessary when
      bootstrapping a new clone or worktree: `pnpm install` already pulls in
      recent published native bindings, so there is nothing to build until
      source changes.
      
      The new guidance:
      
      - Bootstrapping a new clone or worktree does not start with `pnpm
      build-all`. Build only what your work changes: `pnpm --filter=next
      build` for core-only JS edits, `pnpm build` when JS changes span
      packages.
      - Switching branches or pulling can still require a build when it moves
      JS or Rust source relative to your build outputs; rebuild the affected
      parts before running tests.
      - `pnpm build-all` is reserved for Rust/Turbopack changes, or for when
      Next.js fails to start because native binding changes landed on canary
      after the last npm publish (cross-referenced from the Stale Native
      Binary section).
      
      The `backport-pr` skill repeated the old branch-switch rule and is
      updated to the same policy.
      
      <!-- NEXT_JS_LLM -->
      Co-authored-by: 's avatarClaude Code <noreply@anthropic.com>
      9ff761f2
    • Jan Kassens's avatar
      Fix webpack build dependency cell creation order (#100597) · 7657545d
      Jan Kassens authored
      ## Summary
      
      Fix the `no-map-async-cell` violation in webpack loader build-dependency
      tracking so `ast-grep scan --format github` passes again. Prepare
      resolver options concurrently, then create their cells synchronously in
      request order before resolving modules concurrently. This prevents async
      completion order from determining Turbo Tasks cell order.
      
      CI context: bc37b30d (#100569) aligned
      the CI ast-grep version with the repository (0.31.0 → 0.42.0), restoring
      enforcement of lint failures. #100562 fixed the analyzer occurrence, but
      #99549 subsequently introduced this occurrence in
      `build_module_requests_changed`.
      
      Tradeoff: the two phases add an intermediate vector allocation and a
      synchronization barrier: all options must be prepared before any module
      resolution starts. This may reduce overlap; the performance impact has
      not been measured. There may be a better approach, such as reading the
      shared resolver options once and synchronously cloning/customizing them
      before creating cells, avoiding the extra preparation join.
      
      ## Verification
      
      - `pnpm exec ast-grep scan --format github`
      - `ast-grep test` (7 passed)
      - `cargo fmt --all -- --check`
      - `cargo check -p turbopack-node --offline`
      - `pnpm build-all`
      
      <!-- NEXT_JS_LLM -->
      7657545d
    • Jan Kassens's avatar
      Pass lazy response lifecycle capabilities into App rendering (#100395) · 676b665e
      Jan Kassens authored
      ## Summary
      
      Continue decoupling App Router rendering from HTTP responses by binding
      lazy development response capabilities at the route-module boundary. HMR
      cancellation, validation scheduling, and worker snapshots use these
      capabilities instead of accessing `originalResponse` in the renderer.
      
      Preserves listener registration timing, abort reasons, live completion
      state, and the response wrapper's preview-cookie synchronization. Adds
      unit coverage for these behaviors and scoped import restrictions to keep
      response lifecycle access at the adapter boundary.
      
      ## Verification
      
      38 test executions passed:
      
      - Lifecycle and existing response-completion unit tests: 11.
      - `test-dev-turbo`: HMR cancellation, validation scheduling, and worker
      source maps: 11; 9 snapshots.
      - `__NEXT_CACHE_COMPONENTS=true test-dev-turbo`: HMR cancellation and
      static-shell validation: 8; 1 snapshot.
      - `test-dev-webpack`: HMR cancellation and validation scheduling: 6.
      - `test-start-webpack`: standalone Node/Edge bundling: 2.
      
      <!-- NEXT_JS_LLM -->
      676b665e
    • Jimmy Miller's avatar
      More parity for webpack loader build dependencies (#99549) · 443a9e7a
      Jimmy Miller authored
      Track transitive modules, resolution requests, and package directories.
      443a9e7a
    • Jan Kassens's avatar
      Upgrade testmode interceptors to 0.45.9 (#100585) · 0954164b
      Jan Kassens authored
      ## Summary
      
      Upgrade the interceptor vendored for experimental test mode from
      `0.42.6` to `0.45.9` and regenerate its bundle. Leave the separate
      interceptor dependency pulled in by MSW unchanged.
      
      The old bundle can crash Node with `SIGSEGV` when an HTTPS keep-alive
      socket receives two mocked responses with `Content-Length`, then
      switches to real socket passthrough. The first fixed upstream release
      was `0.45.6`
      ([mswjs/interceptors#851](https://github.com/mswjs/interceptors/pull/851));
      `0.45.9` also includes subsequent socket and HTTP fixes. The affected
      dependency entered Next.js in `16.3.0-canary.98` via #96059.
      
      ## Verification
      
      - Existing `test/e2e/testmode/testmode.test.ts`: all 16 tests passed in
      each of `test-dev-turbo`, `test-dev-webpack`, `test-start-turbo`, and
      `test-start-webpack`.
      - Local Next.js-level A/B reproduction using a route handler, test
      proxy, and loopback HTTPS server: two mocks followed by true passthrough
      using Next's internal request marker. Substituting the base revision's
      exact `0.42.6` bundle reproduced `SIGSEGV` on Node 24.14.0; the `0.45.9`
      bundle passed with the same socket reused. The upgraded fixture passed
      in all four modes above and on Node 24.14.0. This temporary fixture is
      not included in the PR.
      - Standalone checks passed on Node 20.20.2 and 24.14.0 for TLS
      keep-alive reuse, per-request authentication headers, response event
      counts, and abort recovery.
      
      <!-- NEXT_JS_LLM -->
      0954164b
    • Jimmy Miller's avatar
      Extend lazy server imports to route handlers and Pages (#99541) · 50bf604f
      Jimmy Miller authored
      Enable development-only lazy imports for Node.js route handlers, Pages
      API routes, and Pages SSR while keeping startup entries eager.
      50bf604f
    • Jan Kassens's avatar
      Defer React loading until fetch dedupe construction (#100401) · 417f8c0d
      Jan Kassens authored
      ## Summary
      
      Avoid initializing React when the router server and fetch helpers are
      imported. Load React when constructing the fetch deduplication helper,
      and share the fetch-patched symbol through a standalone module so the
      router server can access it without loading the fetch patcher.
      
      Removed the lazy module evaluation unit test following review feedback.
      
      ## Verification
      
      - Previously validated fetch deduplication and fetch patching unit
      tests, plus
      `test/e2e/app-dir/app-fetch-deduping/app-fetch-deduping.test.ts` in
      development with Turbopack and production with webpack.
      - Rebased onto `canary` (`3f51f6e6`); confirmed the implementation
      patches are unchanged. Tests were not rerun for the test deletion.
      
      <!-- NEXT_JS_LLM -->
      417f8c0d
    • Jamiboy Mohammad's avatar
      test: enable log-file and worker-react-refresh in deploy mode (#100480) · 331a4692
      Jamiboy Mohammad authored
      ## Summary
      
      Removes the `TODO(deploy-test-completion)` exclusion from two suites
      that already pass against a Vercel deployment:
      
      - `test/e2e/app-dir/log-file/log-file.test.ts` — passed in 6 deploy jobs
      (normal and Cache Components, 55–75s each) when its gate was removed in
      the Sept 9 retry runs, e.g. [run
      34404668278](https://github.com/vercel/next.js/actions/runs/34404668278)
      and [run
      34404667354](https://github.com/vercel/next.js/actions/runs/34404667354).
      The browser-log assertions run for real; the `next-development.log`
      check in the non-dev branch only asserts the log file is absent, which
      also holds for a deployment.
      - `test/e2e/worker-react-refresh/worker-react-refresh.test.tsx` — passed
      in both deploy variants (~60s each) of [run
      36052929022](https://github.com/vercel/next.js/actions/runs/36052929022)
      from #99187.
      
      Both files are unchanged since those runs apart from the gate itself and
      a dev-only snapshot line.
      
      Three other suites that looked green in the same runs are not included:
      `404-page-router`, `draft-mode`, and `app-dir/actions/app-action-export`
      each had an in-file `isNextDeploy`/`!isNextStart` early return at the
      time, so the deploy job only ran a placeholder test.
      
      ## Verification
      
      - Checked neither suite is listed in `test/deploy-tests-manifest.json`.
      - Not run locally in deploy mode (no `VERCEL_TEST_TOKEN` locally); this
      PR's deploy job covers it.
      
      <!-- NEXT_JS_LLM -->
      331a4692
    • Jamiboy Mohammad's avatar
      ci: only declare a Vercel deploy target for webpack runs without a custom script (#100479) · e56e53c9
      Jamiboy Mohammad authored
      ## Summary
      
      `test_e2e_deploy_release.yml` can be dispatched with a custom deploy
      script to run the deploy suite against another platform's adapter. The
      webpack job still set `NEXT_TEST_DEPLOY_TARGET_VERCEL=1` in that case,
      so tests gated on the `vercel` condition from #99837 ran against the
      other platform instead of being skipped.
      
      The webpack job now sets it only when no custom deploy script is given,
      as the Turbopack job already does. The adapter job is unchanged: it
      doesn't accept custom scripts, so it always deploys to Vercel.
      
      ## Verification
      
      - The webpack and Turbopack jobs now use the same
      `NEXT_TEST_DEPLOY_TARGET_VERCEL` expression, and the workflow still
      parses.
      - Not run: a dispatched `test-e2e-deploy-release` run
      (`workflow_dispatch` only).
      
      <!-- NEXT_JS_LLM -->
      e56e53c9
    • Niklas Mischkulnig's avatar
      Turbopack: Honor PURE annotations for callback arguments (#100577) · 68f20d1c
      Niklas Mischkulnig authored
      ## Summary
      
      Honor PURE annotations without treating function arguments as invoked
      when checking call and constructor side effects. Continue checking
      argument evaluation, while retaining conservative callback handling for
      unannotated known builtins.
      
      ## Verification
      
      - Not run: tests (split existing commits into a PR stack; no source
      changes).
      
      <!-- NEXT_JS_LLM -->
      68f20d1c
    • Jan Kassens's avatar
      Avoid loading standalone React by separating render validation (#100467) · cc02d668
      Jan Kassens authored
      ## Summary
      
      App Router server traces currently include the installed React package
      through shared framework modules. This separates render validation from
      dynamic tracking so server bootstrap imports cannot reach the validation
      code's React lookup. Validation keeps its direct `require('react')`
      inside renderer bundles, where bundler aliases select the appropriate
      React instance. The fetch patch marker also moves to a standalone module
      so reading it does not load the fetch implementation.
      
      The adapter minimal-server trace drops the installed React files and six
      validation-only framework files.
      
      This is an independent alternative to using the renderer React registry
      in #100466. These solutions are for comparison; only one should land.
      
      ## Performance
      
      Compared `bfe0ccd57f` against its immediate parent, `72895219`, in a
      small production `next start` benchmark on October 20, 2026. Both
      revisions used release builds, Turbopack-built applications, Node
      24.21.0, and the same dependencies on an Apple M5 Pro. Cache Components
      and Partial Prefetching remained enabled.
      
      | Measurement | Base → branch | Change |
      | --- | --- | --- |
      | JavaScript files loaded through the first API/static response | 473 →
      463 | 10 fewer files |
      | JavaScript files loaded through the first dynamic response | 476 → 466
      | 10 fewer files |
      | Loaded file-backed JavaScript source | About 214 KiB less | About 4.8%
      reduction |
      | Median process start → complete API response | 171.36 → 168.79 ms |
      1.50% faster |
      | Median process start → complete static response | 168.60 → 167.33 ms |
      0.75% faster |
      | Median process start → complete dynamic response | 412.08 → 410.69 ms
      | 0.34% faster |
      
      Startup measurements used 30 paired fresh-process trials per route,
      alternating revision order, with TCP-only readiness and exactly one HTTP
      request. The branch completed sooner in 29/30 API pairs; the dynamic
      startup result was inconclusive. Separate instrumented captures
      reproduced the same loaded-file sets twice; source sizes describe files
      loaded by the server, not browser downloads or allocated memory.
      
      Warm throughput was essentially unchanged across five paired trials per
      route: API −0.53%, static −0.11%, dynamic 0%. Each trial used 3 seconds
      of warmup, 10 seconds of measurement, and 50 keep-alive connections. The
      dynamic fixture includes a 200 ms wait, which limits its sensitivity to
      rendering overhead. All load trials completed without errors, timeouts,
      or non-2xx responses, and both revisions passed API, static response,
      dynamic freshness, and streaming behavior checks.
      
      These local measurements used warm filesystem caches and shared-machine
      load generation. They show reduced eager dependency loading and a modest
      API startup benefit; they do not establish serverless cold-start gains
      or a material warm-throughput improvement.
      
      ## Verification
      
      - `pnpm test-start-turbo
      test/production/next-server-nft/next-server-nft.test.ts` — 6 tests and 5
      snapshots passed.
      - `pnpm test-start-webpack test/e2e/app-dir/app/standalone.test.ts` — 2
      tests passed, including Edge runtime bundling.
      
      - Existing Cache Components error coverage for RSC (Dynamic Root) and
      SSR (`useSearchParams`) passed with both Turbopack and webpack: 2 tests
      and 2 snapshots per bundler.
      - `pnpm test-dev-turbo
      test/e2e/app-dir/cache-components-errors/{client,sync-dynamic}.test.ts
      -t 'useSearchParams in Client Components|Dynamic Root'`
      - `pnpm test-dev-webpack
      test/e2e/app-dir/cache-components-errors/{client,sync-dynamic}.test.ts
      -t 'useSearchParams in Client Components|Dynamic Root'`
      
      <!-- NEXT_JS_LLM -->
      cc02d668
    • Tobias Koppers's avatar
      test: add non-adapter deploy snapshots to otel-middleware-trace (#100583) · f196a3a5
      Tobias Koppers authored
      ### What?
      
      Adds snapshots for deployments built without the adapter to
      `test/e2e/app-dir/otel-middleware-trace/otel-middleware-trace.test.ts`.
      Test-only change.
      
      ### Why?
      
      The v16.5.0-canary.23 release deploy tests ([run
      39773330104](https://github.com/vercel/next.js/actions/runs/39773330104))
      fail 20 of 30 tests in this file, on every retry, in `Run Deploy Tests
      (Turbopack)` and `Run Deploy Tests (Webpack)`. Those jobs deploy with
      `NEXT_ENABLE_ADAPTER=0`. The deploy snapshots were filled from PR CI,
      which deploys only through the adapter (`NEXT_ENABLE_ADAPTER=1`). `Run
      Deploy Adapter Tests` passes the same file.
      
      Without the adapter, the trace topology is the same: one trace, and the
      middleware and render are siblings under `Next.request` or the incoming
      context. Only the render's spans have the self-hosted shape:
      - the request span is unnamed (`GET` instead of `GET /page/page`);
      - `findPageComponents` → `loadRouteModule` spans appear;
      - the render's `instrumentation.ts` lifecycle spans are startup roots.
      Node.js middleware still emits its lifecycle spans inside the middleware
      span.
      
      ### How?
      
      - **Builder flag.** A new `isNonAdapterDeploy` flag selects non-adapter
      snapshots for deployments without the adapter, in the default render
      mode.
      - The snapshots are the complete received trees from that run. They were
      identical across Turbopack and Webpack and all 3 attempts.
        - The lifecycle-span test reuses the existing self-hosted snapshot.
      - **Existing snapshots unchanged.** All adapter, self-hosted and Cache
      Components snapshots stay as they are. Non-adapter deployments with
      Cache Components keep the existing assertions, because the release suite
      doesn't run that combination, so there's no observed tree to assert.
      - **No coverage dropped.** No deployment skips or known-failure entries.
      
      Verification:
      - **Mechanical checks.** The new literals were checked against the trees
      reconstructed from the CI logs. A check of which snapshot each of the
      192 test/environment combinations selects confirms that only
      default-mode non-adapter deployments change.
      - **Local runs.** `test-start-turbo`, `test-dev-turbo` and
      `test-start-webpack` pass with no snapshot changes.
      - **Not confirmed by PR CI.** PR CI deploys only through the adapter, so
      it doesn't exercise the new snapshots. The next release deploy run
      confirms them.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet ce0ecb23-b14c-4679-92a9-e676130f618e -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
      f196a3a5
    • next-js-bot[bot]'s avatar
      Update Rspack development test manifest (#100557) · 4e28b0ee
      next-js-bot[bot] authored
      This auto-generated PR updates the development integration test manifest
      used when testing Rspack.
      Co-authored-by: 's avatarnext-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
      4e28b0ee
    • next-js-bot[bot]'s avatar
      Update Rspack production test manifest (#100558) · 9b67817b
      next-js-bot[bot] authored
      This auto-generated PR updates the production integration test manifest
      used when testing Rspack.
      Co-authored-by: 's avatarnext-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
      9b67817b
    • Niklas Mischkulnig's avatar
      ci: Fix ast-grep CI step (#100569) · bc37b30d
      Niklas Mischkulnig authored
      The ast-grep versions got out of sync in
      https://github.com/vercel/next.js/pull/94150, causing lint failures to
      not fail CI.
      
      Depends on https://github.com/vercel/next.js/pull/100562 to make CI pass
      again
      bc37b30d
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.23 · 70e1e25b
      next-js-bot[bot] authored
      70e1e25b
    • Sebastian "Sebbie" Silbermann's avatar
      [cd] Move release un-draft to a follow-up job (#100571) · b7808638
      Sebastian "Sebbie" Silbermann authored
      Follow-up to #100121. `publishRelease` no longer mints an App token at
      all.
      
      Un-drafting the GitHub release must stay authenticated as the release
      App: events caused by `GITHUB_TOKEN` do not trigger workflow runs, and
      release-published automations depend on the event. Previously that meant
      the bot key had to be available to the `publishRelease` job. With this
      change a small `undraftRelease` job runs in `bot-autonomous` instead,
      after the gated publish succeeded (the tag is already trusted at that
      point), so the key never leaves the two `bot-*` environments.
      
      Backports: #100572 (`releases/lts/active`), #100573
      (`releases/lts/maintenance`) — their publish scripts read `lerna.json`,
      so the script is adapted there.
      
      ---------
      Co-authored-by: 's avatarClaude Code <noreply@anthropic.com>
      b7808638
    • zydo's avatar
      Fix analyzer cell creation order (#100562) · 684cf7ea
      zydo authored
      ## Summary
      
      Prepare each endpoint group asynchronously, then create its chunk-group
      and route-entry cells in endpoint order. This makes cell creation
      deterministic and satisfies the `no-map-async-cell` lint rule without
      changing the analyzer's output.
      
      ## Verification
      
      - `pnpm lint-ast-grep`
      - `pnpm build-all`
      - `cargo fmt --all -- --check`
      - `TMPDIR=/private/tmp pnpm test-start-turbo
      test/e2e/next-analyze/next-analyze.test.ts` (6 tests passed)
      
      <!-- NEXT_JS_LLM -->
      684cf7ea
    • Hendrik Liebau's avatar
      [ci] Run flakiness detection under concurrent load (#100525) · 3da24ee7
      Hendrik Liebau authored
      The flakiness detection jobs ran three attempts sequentially with
      concurrency set to one, while regular test jobs run up to eight suites
      at once. The response-read flake addressed by #100514 passed all three
      checks for #100447, which prompted this change.
      
      The detector now queues three runs per suite in one runner and uses the
      job's configured concurrency. Each run has an isolated application
      directory and separate results, traces, and failure tracking. Retries
      and result caching remain disabled so every run executes and any failure
      fails the job.
      
      The testing guide documents how to keep concurrent runs independent and
      allocate listening ports dynamically.
      3da24ee7
    • Hendrik Liebau's avatar
      [test] Avoid port collisions in concurrent OpenTelemetry tests (#100538) · 2d139451
      Hendrik Liebau authored
      Both OpenTelemetry suites used fixed collector ports, and the
      instrumentation suite also used a fixed gate-server port. These ports
      could collide when #100525 runs multiple copies of a suite.
      
      Collectors now bind to OS-assigned ports and pass their ports to the
      fixtures before startup. The parent-span suite resets spans while its
      collector remains open. The gate server uses a dynamically selected
      port. The streamed-render helper starts the gate timeout after response
      headers, so cold dev compilation does not consume the deadline.
      2d139451
    • Hendrik Liebau's avatar
      [test] Avoid port collisions in concurrent keep-alive tests (#100537) · 3a0a7caf
      Hendrik Liebau authored
      The suite bound every mock server to port 44001, so the concurrent runs
      in #100525 could fail with EADDRINUSE. Each run now uses an OS-assigned
      port and passes its server URL to the fixture.
      
      The suite also awaits server shutdown.
      3a0a7caf
    • next-js-bot[bot]'s avatar
      Upgrade React from `a6792708-20261019` to `ab0d927f-20261020` (#100527) · 70e94d8e
      next-js-bot[bot] authored
      [diff
      facebook/react@a6792708...ab0d927f](https://github.com/facebook/react/compare/a6792708...ab0d927f)
      
      <details>
      <summary>React upstream changes</summary>
      
      - https://github.com/facebook/react/pull/37916
      
      </details>
      
      ---------
      Co-authored-by: 's avatarnext-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
      70e94d8e
    • Tobias Koppers's avatar
      Preserve deferred middleware instrumentation spans when the adapter throws (#100552) · b0d01507
      Tobias Koppers authored
      ### What?
      
      Direct Node.js middleware/proxy entrypoints now emit the deferred
      `instrumentation.ts` lifecycle spans (`load instrumentation module`,
      `register instrumentation`) even when the adapter rejects the request
      before it runs the middleware.
      
      ### Why?
      
      Follow-up to #100350. When a request to the Node.js middleware
      entrypoint triggers `instrumentation.ts` registration, the lifecycle
      spans are deferred and emitted inside the `Middleware.execute` span. If
      adapter setup throws first (e.g. the configured cache handler throws
      while the adapter builds the request's incremental cache), the emitter
      is never called. Registration has already completed, so no later request
      receives it either, and those spans are lost for the lifetime of the
      instance.
      
      This only affects direct entrypoints (adapters, deployments). `next
      start` / `next dev` register instrumentation at startup.
      
      ### How?
      
      - The middleware entrypoint template, which owns the deferred emitter,
      now awaits the adapter in a `try/catch`. On error it calls the emitter,
      then rethrows the original error unchanged. The adapter and its options
      are unchanged.
      - The emitter already emits at most once, so the fallback does nothing
      when the spans were already emitted inside `Middleware.execute` (e.g.
      the user's middleware threw). Successful requests keep their existing
      span parentage. In the fallback case there is no middleware span, so the
      spans are emitted in the caller's active context (or as roots).
      - The fallback call is guarded so that a failure while tracing can't
      replace the adapter's error.
      
      **Test:** this reuses the existing direct-entrypoint OpenTelemetry
      harness (`test/e2e/opentelemetry/instrumentation`, `next start` only).
      The harness calls the built middleware entrypoint's `handler` with a
      real `Request`, like the Vercel adapter does.
      - The fixture's custom cache handler throws from its constructor when a
      test-only request header is set. The adapter constructs it per request,
      before running the middleware.
      - A new suite, in a fresh process, sends that request through the normal
      middleware flow and asserts that:
        - the original error propagates;
      - both lifecycle spans are collected exactly once, with no
      `Middleware.execute` span;
        - a later valid request succeeds without emitting them again.
      - The test fails without the fix.
      
      ### Verification
      
      - New test plus the existing "should trace instrumentation registration
      in the first middleware request" variants: `pnpm test-start-turbo` and
      `pnpm test-start-webpack` on
      `test/e2e/opentelemetry/instrumentation/opentelemetry.test.ts`
      - `pnpm jest
      packages/next/src/server/lib/router-utils/instrumentation-globals.test.ts`
      - `pnpm --filter=next types`, `pnpm typescript`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet bb16cbee-5cda-4702-b442-ea49bf648fe0 -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
      b0d01507
    • Hendrik Liebau's avatar
      Fix cache revalidation queued during streaming (#100448) · c58836ae
      Hendrik Liebau authored
      Next.js previously flushed revalidations after preparing the HTML stream
      or running a Route Handler, before the response body finished streaming.
      That flush dispatched queued tags and collected existing background
      cache promises. Work added during streaming was omitted, so later cache
      regeneration lacked `waitUntil` coverage and later tag invalidations
      were never dispatched.
      
      This extends the response-close approach proposed in #99772 beyond
      dynamic HTML to Flight responses, Route Handlers, and streamed Server
      Actions. `AfterContext` registers a `waitUntil` promise before the
      handler returns and flushes newly queued work at close. Its snapshot
      excludes earlier flushes and runs before `after()` callbacks start, so
      their invalidations wait for callback completion. The change also
      handles already-closed Node responses and Edge error paths that must
      release close waiters. Server Action barriers retain their existing
      ordering.
      
      Fixes #99339
      Fixes #99566
      Closes #99772
      c58836ae
    • Tobias Koppers's avatar
      turbopack: use reverse postorder priority in compute_binding_usage_info (#100440) · fa3830c4
      Tobias Koppers authored
      Stacked on #100430 (#100428 → #100429 → #100430 → this).
      
      ### What?
      
      Two changes in `compute_binding_usage_info`:
      
      1. **Reverse postorder priority.** The fixed-point traversal now uses
      `Reverse(rank)` from `ModuleGraphSnapshot::reverse_postorder_ranks`
      (added in #100428) as its priority, instead of the constant `0`. Modules
      are visited roots first, so in an acyclic graph each module is processed
      exactly once, after all of its importers and with its final usage.
      Cycles still rely on the fixed point.
      2. **No clone of the parent's usage on passthrough edges.** The
      `ExportUsage::Passthrough` branch cloned the parent's
      `ModuleExportUsageInfo` to work around borrowing two entries of
      `used_exports` at once. It now inserts the target's entry, borrows both
      entries with `HashMap::get_disjoint_mut`, and merges directly. A
      self-edge (`parent == target`) is handled explicitly, because merging a
      usage into itself never changes it and `get_disjoint_mut` would panic on
      the duplicate key.
      
      ### Why?
      
      With the constant priority, the traversal pops the most recently queued
      node first, which makes the order DFS-like. That gives no ordering
      guarantee: a shared module can be processed before all of its importers,
      and is then revisited whenever a later importer adds new export names.
      
      On the apps measured below this happens rarely, so there is no speedup
      here. The extra rank traversal makes the analysis **slower** on both
      apps. The change is meant as protection against worst cases in apps
      where shared modules are imported with different names at many different
      depths. In those, the number of revisits is no longer order-dependent on
      DAG-shaped graphs.
      
      ### Benchmarks
      
      Real Turbopack `next build --experimental-build-mode compile` runs with
      release `next-swc` builds (LTO off, 16 codegen units). Builds were
      interleaved on the same machine, 3 runs each. Times are the
      binding-usage analysis (rank pass + fixed point), summed over both
      invocations per build: median [min–max].
      
      | | base (#100430) | + RPO priority | + clone removal (this PR) |
      |---|---|---|---|
      | generated app router app, 300 routes | 11.2 ms [10.8–11.7] | 14.7 ms
      [13.2–16.0] | 14.1 ms [13.4–15.7] |
      | `bench/nested-deps-app-router-many-pages` | 36.6 ms [35.5–37.6] | 52.4
      ms [51.0–68.8] | 55.7 ms [52.9–57.3] |
      
      | | visits (base → this PR) | rank pass (median) |
      |---|---|---|
      | generated app | 27,128 → 24,228 | 4.7 ms |
      | many-pages | 64,894 → 64,606 | 14.2 ms |
      
      - **Revisits:** RPO removes almost all of them; 25 remain, inside or
      right after cycles. Under the constant priority, though, 88% and 99.6%
      of modules were already visited only once, so there is little to save.
      - **Rank pass:** it is a near-full extra traversal, and it costs more
      than the saved revisits on both apps.
      - **Clone removal:** no measurable difference within noise on these
      apps.
      
      ### How was it verified?
      
      - `cargo test -p turbopack-core --lib`, `cargo test -p turbopack-tests
      --test snapshot` (no snapshot changes) and `cargo test -p
      turbopack-tests --test execution` all pass.
      - `cargo clippy -p turbopack-core --all-targets -- -D warnings` and
      `RUSTDOCFLAGS='-D warnings' cargo doc -p turbopack-core --no-deps` are
      clean.
      - Output equivalence on both benchmark apps: I compared a local, not
      committed, fingerprint of the analysis result between the base and this
      PR, covering per-module used exports, partial-namespace modules and
      unused-reference targets. It is identical for both invocations.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet b56269ed-2145-4f30-b0fe-dc9762520521 -->
      
      ---------
      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>
      fa3830c4
    • Tobias Koppers's avatar
      turbo-tasks: unemit taken collectibles in a single backend operation (#100437) · 2e133c98
      Tobias Koppers authored
      ### What?
      
      `take_collectibles` / `drop_collectibles` now unemit all taken
      collectibles in a single backend operation instead of one operation per
      collectible.
      
      ### Why?
      
      `TurboTasks::unemit_collectibles` looped over every collectible and
      called `Backend::unemit_collectible` for each. In `TurboTasksBackend`
      every one of those calls locked the task, built its own aggregation
      update queue and propagated a single-entry collectibles update through
      the aggregation graph. With many collectibles that means one task lock
      and one aggregation graph update per collectible.
      
      ### How?
      
      - New required `Backend::unemit_collectibles` trait method.
      `TurboTasks::unemit_collectibles` calls it once, and does nothing when
      no count is positive.
      - `TurboTasksBackend` implements it with a batched
      `UpdateCollectibleOperation::run_batch`:
        - locks the task once and checks the root-task restriction up front;
      - reconciles each collectible against its outdated count, with the same
      per-collectible semantics as before;
      - invalidates collectible dependents at most once per collectible type;
      - propagates all remaining changes as one aggregated data update, so the
      aggregation queue runs once.
      - `AggregatedDataUpdate`'s collectibles update is now a `SmallVec<[_;
      1]>`, so single-collectible updates don't heap-allocate and the batch is
      handed over without conversion.
      - The single-collectible `UpdateCollectibleOperation::run` now goes
      through the same code path.
      
      New regression test `tests/collectibles_take_batch.rs` covers:
      - take and drop;
      - the same collectible emitted several times, from one task and from two
      tasks;
      - several uppers;
      - the set of collectibles changing between re-executions;
      - a nested take;
      - taking from a source with no collectibles.
      
      It passes both before and after this change.
      
      ### Benchmark
      
      New criterion benchmark `benches/collectibles.rs`. A root task takes (or
      peeks) N collectibles of an operation, below a chain of 8 tasks.
      Emission happens outside the timed region.
      
      ```
      cargo bench -p turbo-tasks-backend --bench mod -- collectibles
      ```
      
      Medians from two interleaved base/new rounds on one 8-core VM:
      
      | N | base | new | change |
      |---|---|---|---|
      | 1,000 | 655 µs / 575 µs | 438 µs / 384 µs | −33% / −33% |
      | 10,000 | 4.8 ms / 4.9 ms | 3.2 ms / 2.9 ms | −34% / −41% |
      
      For N = 10 and 100 there was no consistent difference. The VM's
      run-to-run noise there (±15–25%, also for the unchanged `peek` variant)
      is larger than any effect.
      
      ### Verification
      
      - `cargo test -p turbo-tasks -p turbo-tasks-backend`
      - `cargo clippy -p turbo-tasks -p turbo-tasks-backend --all-targets --
      -D warnings`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 53aa7530-1b3f-423b-8eb2-29bf4b657aba -->
      
      ---------
      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>
      2e133c98
    • Luke Sandberg's avatar
      Bump turbo to 2.11.10 (#100549) · fa1eab66
      Luke Sandberg authored
      ## Summary
      
      Bumps turbo from 2.11.7 to 2.11.10 to pick up the fix for
      https://github.com/vercel/turborepo/issues/14668, which is believed to
      cause CI hangs such as
      https://github.com/vercel/next.js/actions/runs/39653289579/job/119407185916.
      
      Updated:
      
      - `turbo` devDependency in the root `package.json` (+ `pnpm-lock.yaml`,
      turbo / `@turbo/*` entries only)
      - `TURBO_VERSION` in `.github/workflows/build_and_deploy.yml`,
      `build_reusable.yml` and `trigger_release.yml` (used by every `pnpm dlx
      turbo@${TURBO_VERSION}` call, including those in `build_and_test.yml`)
      
      ## Verification
      
      - `pnpm install --frozen-lockfile --ignore-scripts` (lockfile up to
      date)
      - `pnpm turbo --version` → `2.11.10`
      - Whether the hang is resolved can only be confirmed in CI
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet b2f9442e-0aa6-466e-a973-9c27796fa63f -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      fa1eab66
  3. 21 Oct, 2026 6 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.22 · 13ae649e
      next-js-bot[bot] authored
      13ae649e
    • Jamiboy Mohammad's avatar
      Remove unnecessary `as any` casts (#100418) · ce9c8008
      Jamiboy Mohammad authored
      ## Summary
      
      Deletes 69 `as any` casts from `packages/next/src` (466 → 397) where the
      existing types already make the cast unnecessary.
      
      Each change only removes ` as any`, plus any parentheses that become
      redundant. Nothing else is added or changed: no new declarations,
      fields, annotations, helpers, or replacement assertions. The emitted
      JavaScript is identical, so there is no runtime change.
      
      How the casts were found:
      
      1. Delete every `as any` in `packages/next/src`, locating them through
      the TypeScript AST rather than text search.
      2. Run `tsc`, put back each cast whose removal caused an error, and
      repeat until clean.
      3. Retry the casts that were put back one at a time, so removals in the
      same file can't mask each other.
      
      Casts that need a type change, a declaration, or code changes to go away
      are left to #100419.
      
      ## Verification
      
      - Transpiled each changed file on `canary` and on this branch with
      `ts.transpileModule` (the package's compiler options, comments stripped)
      and compared the output, ignoring whitespace and semicolons: 44/44
      identical.
      - `tsc --noEmit` passes for `packages/next` and for the root project.
      - Colocated jest suites for the touched files pass (9 suites).
      
      <!-- NEXT_JS_LLM -->
      ce9c8008
    • next-js-bot[bot]'s avatar
      Update font data (#100490) · 9ff8ba95
      next-js-bot[bot] authored
      This auto-generated PR updates font data with latest available
      Co-authored-by: 's avatarnext-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
      9ff8ba95
    • Luke Sandberg's avatar
      Turbopack: lazily compile lazy import.meta.glob matches (#100523) · b83d8f57
      Luke Sandberg authored
      ## Summary
      
      When lazy compilation of dynamic imports is enabled
      (`experimental.turbopackLazyDynamicImports`), lazy `import.meta.glob`
      matches now get the same treatment: each matched module is compiled only
      once its thunk is first called. Eager matches are unaffected.
      
      
      ## Verification
      
      - Added a `/glob` case to
      `test/development/app-dir/lazy-dynamic-imports`.
      
      <!-- NEXT_JS_LLM -->
      b83d8f57
    • Luke Sandberg's avatar
      Turbopack: preserve chunk load promise identity (#100421) · 6204bf03
      Luke Sandberg authored
      ## Summary
      
      #98836 added an on-demand `__turbopack_ensure_chunk__` hook to the
      Turbopack Node dev runtime by overriding `__turbopack_context__.l`. The
      override returned `ensured.then(() => loadChunkAsync(...))`, so every
      call that hit a not-yet-cached chunk produced a **new promise**, and the
      first caller's promise never matched the one later callers got from
      `chunkCache`. That broke referential identity for `__next_chunk_load__`
      (which wraps `.l`), which React relies on. It also created extra
      promises for React's dev async tracking to process.
      
      This change makes `loadChunkAsync` itself aware of
      `__turbopack_ensure_chunk__`:
      
      - The hook is called synchronously on a cache miss. If it returns
      `undefined` (nothing to compile), the chunk is required synchronously
      and the shared pre-resolved promise is cached, exactly as without the
      hook.
      - If it returns a promise (the chunk is being compiled on demand), a
      single `ensure → require/install` promise is cached in `chunkCache`
      immediately. Concurrent and later callers all get the same promise until
      `clearChunkCache()`.
      - If ensuring the chunk fails (a synchronous throw or an async
      rejection), the failure is not cached, so the next load retries.
      `require` failures stay cached as `ChunkLoadError`, as before.
      - The separate `.l` override and `chunksBeingEnsured` map in
      `dev-base.ts` are removed. The Node runtime snapshots are regenerated.
      
      On the Next.js side, the dev hook is now a plain function. It returns
      synchronously for chunks that aren't lazy-compilation chunks, or that
      have no matching entries, and returns a promise only when it actually
      activates a lazy chunk.
      
      ## Verification
      
      - `pnpm test-dev-turbo
      test/development/app-dir/lazy-dynamic-imports/lazy-dynamic-imports.test.ts`
      (12/12 pass)
      - A scratch Node script against the generated dev and build runtimes,
      with a mocked ensure hook. It checks:
      - async ensure: same promise for concurrent and post-settle calls,
      ensure called once, modules installed only after ensure, and eviction
      plus retry after an ensure failure
      - sync ensure: modules installed synchronously with the shared resolved
      promise, and no caching after a synchronous throw
        - cached `ChunkLoadError`, non-JS chunks, and `clearChunkCache` reset
      
      The identity and sync-path checks fail on the previous runtime and pass
      with this change.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet a53f5f3f-06ac-4812-a068-facaf3b95fe5 -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
      6204bf03
    • Tobias Koppers's avatar
      turbo-tasks: batch invalidation via Invalidator::invalidate_all (#100485) · a0e452b9
      Tobias Koppers authored
      ### What?
      
      Adds a batch invalidation API and uses it wherever many tasks are
      invalidated at once:
      
      - `Invalidator::invalidate_all`, `invalidate_all_with_reason` and
      `invalidate_all_with_reasons` invalidate a set of invalidators as one
      batch.
        - Duplicates are fine: task ids are deduplicated once.
        - Empty input does nothing, and records no reasons.
      - `TurboTasksApi::invalidate_many` / `invalidate_many_with_reasons`
      (implemented by `TurboTasks`) make one `Backend::invalidate_tasks` call,
      which previously had no in-tree callers.
        - Reasons are recorded once, before any work starts.
      - `TurboTasksBackend::invalidate_tasks` splits large batches into chunks
      and invalidates them in parallel, using the same sizing as
      `parallel::for_each_owned` (via the now-public
      `parallel::for_each_chunk`). Batched invalidations report the
      `Invalidator` dirty cause, like single ones.
      - Converted call sites:
      - File watcher: all invalidators of one event batch go in one call, with
      one `WatchChange` reason per path. There is now one `file change` span
      per batch instead of one per invalidator. Its `paths` field lists the
      changed paths, comma separated, capped at 20 with `, ... (N more
      paths)`. The call still happens under the existing invalidation lock.
      - `DiskFileSystem`: whole-filesystem, subtree and after-write
      invalidation. These replace the per-invalidator
      `parallel::for_each_owned` calls and per-invalidator reason clones.
        - `State::set`: all dependents in one call.
      - A new `state_fan_out` criterion bench in
      `turbo-tasks-backend/benches`.
      
      ### Why?
      
      Every multi-task producer called `Invalidator::invalidate` once per
      task. Each call went through `Backend::invalidate_task` →
      `invalidate(smallvec![id])`, which runs its own operation and
      scheduling. So none of these producers got the batched scheduling from
      #100446 (one scheduler queue lock per batch instead of per task), or the
      batched restores of paged-out tasks from #100465, which this PR builds
      on.
      
      ### How?
      
      - **Dirty priority across helper threads.** When an invalidation comes
      from inside a task (e.g. `State::set` in a task), the dirtied tasks get
      that task's priority as their parent priority, which the backend reads
      from the task-local task state. The parallel helper threads don't have
      it. So `invalidate_tasks` reads the priority once, before parallelizing,
      and gives every chunk an `ExecuteContext` with that priority
      (`execute_context_with_priority`;
      `ExecuteContext::get_current_task_priority` returns it instead of the
      task-local). Nothing else of the task state is needed, and other
      contexts are unchanged.
      - **Parallel work inside `with_turbo_tasks`.** `scope_bounded` wrapped
      every job, including jobs it runs on the calling thread, in
      `turbo_tasks_scope`, which panics while `with_turbo_tasks` holds a
      borrow of the instance. Jobs now only enter the scope when the thread
      doesn't already have that same instance. This lets
      `State::notify_mutated` keep using `with_turbo_tasks`.
      - **Unique ids at the backend.** `invalidate_many*` requires unique ids.
      The `Invalidator` helpers dedupe, because the watcher and the filesystem
      can yield the same task for several paths. Debug builds assert
      uniqueness for the whole batch before chunking and again in `invalidate`
      for each chunk; release builds pass the ids through without collecting
      them.
      
      ### Benchmark
      
      ```
      cargo bench -p turbo-tasks-backend --bench mod -- state_fan_out
      ```
      
      - **Setup:** one `State` read by N dependent tasks. Each iteration times
      `State::set` plus a strongly consistent read of the root sum, and
      asserts the result.
      - **Variants:** `resident`, and `evicted`, where everything is
      snapshotted and evicted before each iteration. That eviction step is not
      timed, and it asserts that at least N tasks were evicted.
      - **Comparison:** A/B against this PR's parent on `canary`, with the
      same bench copied in. Six paired runs on one 8-vCPU VM, alternating
      which side runs first.
      - **Revision:** measured on an earlier revision of this PR, before it
      was rebased onto #100465 (batched restores in `invalidate`), and while
      the chunking still lived in `TurboTasks`. The A/B wasn't re-run on the
      current revision, so the numbers don't include #100465's effect on
      either side.
      - **Statistics:** the change is the geometric mean of the per-pair
      ratios, with a 95% t-interval.
      
      | variant / N | median base | median this PR | change (95% CI) |
      |---|---|---|---|
      | resident / 1 | 0.284 ms | 0.288 ms | −7.6% [−32.0%, +25.5%] |
      | resident / 1,000 | 5.278 ms | 5.023 ms | −1.3% [−5.7%, +3.2%] |
      | resident / 10,000 | 61.045 ms | 58.029 ms | −4.7% [−8.3%, −1.0%] |
      | evicted / 1 | 0.258 ms | 0.265 ms | +3.3% [−0.2%, +7.0%] |
      | evicted / 1,000 | 8.295 ms | 6.760 ms | **−19.4%** [−21.6%, −17.2%] |
      | evicted / 10,000 | 91.967 ms | 69.775 ms | **−21.8%** [−25.1%, −18.4%]
      |
      
      - **Evicted:** a clear improvement when the dependents have to be
      restored, from invalidating the chunks in parallel and batching their
      scheduling (measured without #100465's batched restores).
      - **Resident:** a small win at 10k, and no reliable difference at 1k or
      for a single task.
      - **Limits:** the intervals reflect repeatability on one VM, not across
      machines. This is a `State` fan-out microbenchmark, not an end-to-end
      filesystem measurement. The OS page cache was warm.
      
      ### Tests
      
      - **`tests/invalidate_all.rs`:**
      - a 2,000-task batch, large enough to chunk, re-executes every task
      exactly once
        - duplicates in one batch
        - reasons show up in the update info
        - empty batches are no-ops
      - `State::set` inside a task with 2,000 dependents, and
      `parallel::for_each` inside `with_turbo_tasks` (both panic without the
      `scope_bounded` change)
      - a 1,999-task batch invalidated from inside a task leaves every task
      dirty with the same parent priority as one task invalidated on its own
      (fails without the explicit priority: tasks of the helper-thread chunks
      get `Initial`). Re-executions are held back so the dirty state can be
      inspected.
      - **Watcher:** the `paths` span formatting, including truncation.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet d21ddb86-de88-41df-82c7-aa6a29a6165e -->
      
      ---------
      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>
      a0e452b9