1. 17 Oct, 2026 1 commit
  2. 16 Oct, 2026 9 commits
    • Luke Sandberg's avatar
      turbo-persistence: prefetch multi-page SST blocks with MADV_WILLNEED (#100283) · e2e7393c
      Luke Sandberg authored
      ### What?
      
      turbo-persistence SST lookup mappings keep `MADV_RANDOM`, and also
      prefetch whole multi-page blocks:
      
      - **Block hint:** before a block's first full read in an SST open (CRC
      check and decompression), the block's page-aligned range gets
      `MADV_WILLNEED`. The hint is issued before any byte of the block is
      read, header included, and only when the block spans more than one page
      (using the system page size).
      - Medium value blocks bypass the block cache, so they get the hint on
      every read.
        - Already-verified blocks and single-page blocks get no syscall.
      - **Block-offset table:** gets `MADV_WILLNEED` at open, instead of
      `MADV_SEQUENTIAL`.
      - **Unknown page size:** if `sysconf(_SC_PAGESIZE)` fails, block hints
      can't be computed, so `MADV_RANDOM` isn't applied either and the mapping
      keeps default advice (read-around still prefetches). The offset-table
      hint is applied in both cases.
      - **Unchanged:** compaction iteration (`MADV_SEQUENTIAL`), meta/blob
      files, File access mode, non-Unix platforms and the on-disk format.
      
      ### Why?
      
      See #100250.
      - With `MADV_RANDOM` alone, a cold multi-page block is faulted in one
      page at a time.
      - Dropping the advice (the first version of this PR) lets kernel
      read-around fix that, but it also reads neighboring blocks that are
      often never used.
      
      The two variants were compared on a real workload:
      - **Setup:** warm `next build`s of
      `bench/nested-deps-app-router-many-pages`, with a new
      `NEXT_DEPLOYMENT_ID` each build. The cache snapshot contained fresh,
      compacted, hot_bottom and cold_bottom SSTs.
      - **Runs:** cold guest page cache, Linux, 4 KiB pages, 5 rotated trials
      per variant.
      
      | Variant | Median build | Major faults | Cache resident after |
      | --- | --- | --- | --- |
      | canary (`Random`) | 40.0 s | ~101k | 527 MiB |
      | default advice | 39.6 s | ~14.2k | 545 MiB |
      | `Random` + `WillNeed` everywhere (this PR) | 38.2 s | ~13.4k | 527 MiB
      |
      | `WillNeed` for cold_bottom only, default for the rest | 38.8 s |
      ~13.8k | 533 MiB |
      
      - Build times are within run-to-run noise. Cache reads are a small part
      of this build, so this is not a claimed wall-time win.
      - The targeted hints match default advice's fault reduction, with less
      data pulled into the page cache.
      - Reading unneeded pages costs more on slow or compressed backing
      storage such as squashfs. That is another reason to avoid read-around,
      though it wasn't benchmarked here.
      - Not measured: memory pressure, macOS and 16 KiB pages. With 16 KiB
      pages more blocks fit in one page and get no hint.
      
      ### How?
      
      - `get_raw_block_slice` takes a `will_need` flag and issues the hint
      after locating the block, before reading its header.
      - Lookups pass `true` when the block's verified-CRC bit is unset; the
      index block and medium values always pass `true`; iteration passes
      `false`.
      - Adds a `libc` dependency on Unix for `sysconf(_SC_PAGESIZE)`, queried
      once and cached. If it can't be determined, both the block hints and
      `MADV_RANDOM` are skipped.
      - Tests:
      - Linux `/proc/self/smaps` check that lookup mappings carry `rr` and not
      `sr`;
      - a test-only hint log verifying the offset-table hint, multi-page-only
      first-read hints, no hints on re-reads, and per-read medium-value hints;
        - pure page-boundary tests for 4 KiB and 16 KiB.
      - README documents the advice policy.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 5f39f2b2-0882-4566-ae42-cf64574c5747 -->
      
      ---------
      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>
      e2e7393c
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.16 · 6d8388a9
      next-js-bot[bot] authored
      6d8388a9
    • Luke Sandberg's avatar
      test: remove stale deploy gate on cold RSC navigation param caching test (#100285) · d407204c
      Luke Sandberg authored
      ## Summary
      
      `cached navigations › caches params from a cold RSC navigation for
      repeated navigations` was gated with `@gate !deploy || adapter` because
      the legacy Vercel builder incorrectly prerenders params omitted from
      `generateStaticParams`. The old version of the test asserted that the
      omitted `bottom` param was *not* cached on repeat navigations, which the
      legacy builder violated.
      
      #99617 rewrote the test to assert the opposite: repeat navigations to
      `/required-fallback-params/t2/b1` now expect `Bottom: b1` to be served
      from the cache, plus a new check that a different param (`b2`) still
      shows its loading boundary. Both hold on the legacy builder, so the
      inverted gate now fails the deploy suite with "Failing test passed even
      though it was supposed to fail" on both Webpack and Turbopack (e.g. the
      [v16.5.0-canary.15 deploy
      run](https://github.com/vercel/next.js/actions/runs/38825363975/job/116760175009)).
      
      This removes the stale gate so the test runs as a normal assertion in
      deploy mode.
      
      ## Verification
      
      - Not run: deploy tests locally (requires Vercel deploy credentials);
      the linked deploy run shows the test passing on both bundlers once the
      gate inversion is ignored.
      
      <!-- NEXT_JS_LLM -->
      d407204c
    • Andrew Clark's avatar
      Refactor fetchStrategy -> stage and completeness (#99706) · f09aa18f
      Andrew Clark authored
      This is a refactor of the FetchStrategy type.
      
      As the Partial Prefetching design has evolved, FetchStrategy has come to
      represent two independent concepts, which we now model separately: the
      _stage_ (AppStage) of the navigation that an entry was rendered through
      (shell, prefetch, or navigation), and the _completeness_ (Completeness)
      of the rendering through that stage (needs runtime request, cache
      complete but with dynamic holes, or fully complete with no dynamic
      holes). Everywhere that used to accept a FetchStrategy now accepts
      either one or both of these types.
      
      (Note: I've called the type AppStage to distinguish it from the internal
      stages used on the server as part of the rendering algorithm. The stages
      used on the client are the ones we document publicly as part of
      `ensureStatic` and the `prefetch()` and `navigation()` APIs.)
      
      The `completeness` field also replaces the `isPartial` field.
      
      It's possible to express much of the logic using a single enum, as in
      the FetchStrategy model. To prove this, I've extracted most of the
      behavioral changes into earlier PRs, to make this one easier to review.
      But the resulting logic in the new model should be easier to follow. So
      on net, we have the same number of fields but expressed in a way that
      better fits the underlying design:
      
      - Every prefetch task (e.g. a visible Link) has a target stage and level
      of completeness. The task finishes when the cache has entries that match
      _both_ targets.
      - When deciding whether to overwrite an existing entry, a more less
      complete entry must never overwrite a less complete one, even if it
      represents a later rendering stage. For example, a response rendered at
      the Navigation stage cannot overwrite a response written at the Prefetch
      stage if it does not include cookie-dependent data; we must discard it
      and perform a new request.
      
      ---------
      Co-authored-by: 's avatarsparkly-dev <338975655+sparkly-dev@users.noreply.github.com>
      f09aa18f
    • Jan Kassens's avatar
      Remove dead NextNodeServer.renderHTML (#100284) · 76ddf785
      Jan Kassens authored
      # Human Notes
      
      This deletes some code that appears to be dead but would otherwise need
      to be updated as we refactor other code nearby to pull out `request` and
      `response` from inner functions.
      
      # AI
      
      ## Summary
      
      `NextNodeServer.renderHTML` (and its abstract declaration on
      `BaseServer`) has had no callers since #81944, which removed the last
      call site. Nothing else in `packages/` or `test/` references it.
      
      This removes the method along with everything only it used:
      
      - `lazyRenderAppPage` in `route-modules/app-page/module.render.ts`.
      `lazyPrerenderAppPage` stays because export uses it.
      - The `NextNodeServerSpan.renderHTML` trace span constant. It is no
      longer emitted and is not in either span allowlist.
      - `renderOpts.isPossibleServerAction`. `renderHTML` was its only reader.
      The App Router renderer reads `isPossibleServerAction` from its render
      context, not from `renderOpts`, so the Node and Edge templates no longer
      need to write it. The Pages `RenderOpts` field is unchanged.
      
      This is not public API. The `next()` custom-server wrapper (`NextServer`
      in `server/next.ts`) never forwarded `renderHTML`; it only exposes the
      already-deprecated `render`, `renderToHTML`, `renderError`,
      `renderErrorToHTML` and `render404`. The method is `protected` on both
      server classes, and the only way to reach it is by subclassing
      `NextNodeServer` from `next/dist`. An override there has not run since
      #81944, because nothing calls the method. The span name is not in the
      span allowlists or the docs, and has not been emitted since the same PR.
      
      There is no behavior change. This also means the App page render inputs
      have one fewer producer to keep in sync when they change.
      
      ## Verification
      
      - `tsc --noEmit` for `packages/next`: no errors
      - ESLint and Prettier on the changed files
      - Not run: e2e tests (the deleted code had no callers, so CI covers it)
      
      <!-- NEXT_JS_LLM -->
      
      ---------
      Co-authored-by: 's avatarClaude Opus 5.5 <noreply@anthropic.com>
      76ddf785
    • Jan Kassens's avatar
      Pass Server Action request metadata into App rendering (#100274) · da8f4e92
      Jan Kassens authored
      ## Summary
      
      Pass the existing Server Action classification result into App Router
      rendering instead of repeatedly inspecting the request.
      `ServerActionRequestMetadata` now flows from Node, Edge, direct-server,
      and export adapters through render preparation and action dispatch;
      `prepareAppPage` no longer needs the request object.
      
      Classification rules and action execution behavior are unchanged. This
      continues the request/response boundary cleanup in #99269.
      
      ## Verification
      
      Validated on the exact #99269 base: the Node/Edge unrecognized-action
      suite passed in Turbopack development and Webpack production (26 tests
      each), plus standalone Server Actions in Turbopack production (2 tests).
      
      <!-- NEXT_JS_LLM -->
      da8f4e92
    • Jiwon Choi's avatar
      Fix upgrade eval worktree dependency links (#100257) · ddafc990
      Jiwon Choi authored
      ### Why?
      
      pnpm rejects symlinked task-state paths, so the upgrade evals fail while
      preparing the stable candidate build.
      
      ### How?
      
      Create a real `node_modules` directory in the isolated checkout and link
      the installed dependency entries into it. Leave pnpm task state local to
      that checkout.
      ddafc990
    • Tobias Koppers's avatar
    • Jiwon Choi's avatar
      Respect release age when pinning the upgrade CLI (#100256) · 15e8f35f
      Jiwon Choi authored
      ### Why?
      
      `next upgrade --agent` pins the latest canary without considering the
      package manager's minimum release age, so its delegated CLI can conflict
      with the configured policy.
      
      ### How?
      
      Read npm, pnpm, and Yarn release-age settings and relevant exclusions,
      then pin the highest eligible canary at or below the fetched canary tag.
      Keep the delegated CLI's exact-version guard and stop when settings or
      metadata cannot be read or no eligible canary exists.
      
      For npm, use merged JSON settings with `before` taking precedence over
      `min-release-age`. For pnpm, interpret only the first exclusion matching
      `next`. Read Yarn's effective settings directly. Metadata queries use
      the package manager's normal cache behavior, including cached responses
      when available.
      15e8f35f
  3. 15 Oct, 2026 30 commits
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.15 · a6d4c159
      next-js-bot[bot] authored
      a6d4c159
    • Josh Story's avatar
      Hoist app page request URL into render context (#99269) · 00c4ba8b
      Josh Story authored
      ## Summary
      
      Pass the final app-page request URL explicitly from the Node, Edge, and
      build export entry points into rendering. This keeps URL parsing and the
      deterministic prerender request ID tied to the exact URL observed on the
      request after existing normalization.
      
      Development ISR status bookkeeping uses the forwarded URL with its
      existing URL parsing behavior.
      
      A path-scoped lint guard prevents new direct `req.url` reads in
      app-render.
      
      ## Verification
      
      - `pnpm --filter=next types`
      - `pnpm --filter=next build`
      - Confirmed `rg -n '\breq\.url\b' packages/next/src/server/app-render`
      has no matches.
      - ESLint stdin probes reject `req.url` under app-render with the
      `requestUrl` guidance and allow the same access outside app-render.
      - Not run: integration tests (the worktree lacks per-package
      dependencies, so the full bootstrap build could not complete).
      
      <!-- NEXT_JS_LLM -->
      00c4ba8b
    • Sam Selikoff's avatar
      Hide overlay editor button labels on smaller screens (#100266) · edd8011d
      Sam Selikoff authored
      Hide "Open in editor" button text on small screens.
      
      Follow-up to #100206.
      
      <!-- NEXT_JS_LLM -->
      edd8011d
    • Niklas Mischkulnig's avatar
      Turbopack: don't inherit API route config from parent layouts (#100243) · 96f545ae
      Niklas Mischkulnig authored
      Basically reverts https://github.com/vercel/next.js/pull/63683
      
      API routes don't have "parent layouts" and shouldn't inherit their
      config from anywhere
      96f545ae
    • Niklas Mischkulnig's avatar
      test: Add more segment config tests (#100242) · 7525c5d3
      Niklas Mischkulnig authored
      Add some regression tests about the current behavior
      
      Mostly
      - inheritance across layouts and parallel routes
      - API routes
      
      Turbopack is currently wrong for some of those. See PRs up the stack
      7525c5d3
    • Andrew Clark's avatar
      Prefer non-partial entries regardless of FetchStrategy (#99705) · d50d2ce8
      Andrew Clark authored
      If an entry is not partial, it means nothing was omittted during
      rendering. Regardless of the strategy used to fetch it — static vs
      dynamic, shell vs prefetch vs navigation, etc — it's the most complete
      possible representation of the data. No other fetch strategy could
      return a more complete version.
      
      This PR updates the precedence logic to take `isPartial` into account. I
      discovered this while working on the next PR, which replaces `isPartial`
      with a new "completeness" concept. I extracted it into this earlier PR
      to show how it would be expressed in the current model, so the next one
      is easier to review.
      d50d2ce8
    • Andrew Clark's avatar
      [Partial Prefetching] Don't report vary params in responses that include dynamic data (#99700) · 06136c4a
      Andrew Clark authored
      A navigation response that includes dynamic data should not report any
      vary params, because (until the Ledgers feature lands in React), we
      cannot track params during a streaming render. This updates the server
      to send `null`, which represents an unknown set of params.
      
      The previous structure was mostly harmless because the client only uses
      the vary params when writing to its local cache, and navigation
      responses are not written to the cache (except when they are fully
      static). The one exception is when performing a full prefetch when
      Partial Prefetching is not enabled — the client had a special case to
      ignore the (bogus) vary params sent by the server and treat them as
      unknown. The special case is no longer necessary after this fix.
      
      Now the server's vary params can be treated as authoritative in all
      cases without special handling on the client.
      06136c4a
    • Andrew Clark's avatar
      [Partial Prefetching] Small optimizations and fixes (#99695) · 00f25a86
      Andrew Clark authored
      Fixes a few oversights in the Partial Prefetching implementation that I
      discovered while working on a larger refactor. I've moved these into a
      separate PR so they can be reviewed independently of the upcoming
      restructuring.
      
      These can be reviewed commit-by-commit.
      00f25a86
    • Andrew Clark's avatar
      [Cached Navs] Extract the shell from a fully cached response (#99619) · 8f761662
      Andrew Clark authored
      Fixes an oversight in the Cached Navigations implementation where a
      fully cached navigation response was written into the cache without also
      extracting and writing its shell.
      8f761662
    • Andrew Clark's avatar
      Refactor the navigation fetch and decode layering (#99618) · 88f07ed3
      Andrew Clark authored
      Navigation and prefetch requests go through `createFetch`, which had
      grown several jobs beyond fetching. It decoded navigation responses
      itself (so React DevTools could time the request from the moment it was
      sent), with a flag for prefetches to opt out and a separate wrapper
      stream for HMR refreshes that can be superseded. With Cache Components,
      it also stripped the leading partial marker byte by rebuilding the
      Response around the stripped stream, and tee'd every response so a full
      prefetch could cut its shell from a second copy of the body. Every
      caller paid for the tee and the rebuilt Response, including ones that
      never needed them.
      
      This PR untangles those layers. Each commit can be reviewed on its own.
      
      This is mostly a restructuring, to make the subsequent PRs in the stack
      easier. No meaningful outward behavior changes.
      88f07ed3
    • Andrew Clark's avatar
      [Cached Navs] Don't extract static stage (#99617) · 4b85c280
      Andrew Clark authored
      The original `cachedNavigations` experiment had a behavior where if the
      feature was not enabled for a particular route, the client would cache
      just the static part of the response, since it could be expressed as a
      single byte offset without any additional overhead.
      
      We've since decided Cached Navigations is too important of a feature to
      be opt-in per route. So now it's always enabled (whenever Partial
      Prefetching is enabled).
      
      Therefore it no longer makes sense to extract the static part of the
      response. Instead, we'll do the same thing prefetch responses do, and
      extract out the shell, since the shell can be reused across different
      params values for the same route.
      
      This commit starts by removing the static stage extraction from the
      client. Subsequent steps will unify Cache Navigations extraction with
      the corresponding part of the prefetching implementation.
      
      When Partial Prefetching is enabled, every navigation response can be
      written into the cache: either the entire response is cachable, or it
      contains an embedded inner response that is cacheable. Conceptually it's
      as if each navigation is accompanied by a corresponding prefetch, and
      both requests are returned in the same response.
      
      This unifies the implementation used to write the response (whether it
      comes from a navigation or a prefetch) into the client cache.
      4b85c280
    • Andrew Clark's avatar
      Add more test coverage for non-Partial Prefetching behavior (#100133) · 27accf62
      Andrew Clark authored
      When working on some upcoming refactors of the prefetching
      implementation, I discovered some cases scenarios where we didn't have
      test coverage of non-Partial Prefetch behavior. This adds new tests to
      ensure the behavior does not regress:
      
      - A `prefetch={true}` link fetches only the dynamic data that a default
      prefetch of the same URL left out, and a default link doesn't re-request
      what a `prefetch={true}` link already fetched.
      - Back/forward navigations are served from the back/forward cache
      without requests.
      - A loading-boundary prefetch counts as complete for the segments above
      the boundary, so the navigation requests only the page below it.
      27accf62
    • Sam Selikoff's avatar
      Make error overlay editor actions easier to discover (#100206) · fb20d9af
      Sam Selikoff authored
      Make the "Open in editor" button easier to discover in the error
      overlay. Updates the icon to a Code Wrap icon from Geist.
      
      <img width="1984" height="788" alt="image"
      src="https://github.com/user-attachments/assets/5e633c6a-f4cd-48f9-8925-b42981f20a4b"
      />
      
      <!-- NEXT_JS_LLM -->
      fb20d9af
    • Niklas Mischkulnig's avatar
      chore: Remove package.json#workspaces (#100234) · 169ab67e
      Niklas Mischkulnig authored
      Fix
      ```
      $ pnpm i
      [WARN] The "workspaces" field in package.json differs from "packages" in pnpm-workspace.yaml. pnpm uses pnpm-workspace.yaml.
      ```
      169ab67e
    • Joseph's avatar
      docs: Add Pages Router upgrade guides for versions 15 and 16 (#100247) · 648110d4
      Joseph authored
      ## Summary
      
      The Pages Router docs had no version 15 or 16 upgrade guides. This adds
      both as `source:` stubs that render the App Router guides, and gates the
      App Router-only sections with `<AppOnly>`.
      
      - Version 15: Async Request APIs, `runtime` config, `fetch` caching,
      Route Handlers, and Client Cache are App Router only. The React 19
      minimum is App Router only; a `<PagesOnly>` bullet notes the Pages
      Router supports React 18 and 19.
      - Version 16: Async Request APIs, async metadata image and sitemap
      params, React 19.2 (Canary), Caching APIs, routing and navigation, PPR,
      parallel routes `default.js`, and the
      `dynamicIO`/`useCache`/`unstable_rootParams` removals are App Router
      only. Scroll Behavior Override stays shared (the Pages Router uses the
      same helper) and gets a `pages/_document.tsx` example.
      - App Router-only checklist items move to an `<AppOnly>` block at the
      end of each checklist.
      
      ## Verification
      
      - Not run: `prettier` (local install is broken; committed with
      `--no-verify`, CI lint covers it)
      
      <!-- NEXT_JS_LLM -->
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code)
      648110d4
    • Joseph's avatar
      docs: note that 'use cache: private' results persist across requests in dev (#100252) · 45e09fa4
      Joseph authored
      ## Summary
      
      In `next dev`, `'use cache: private'` results are stored in memory,
      keyed by the request's cookies and headers, and served to the next
      matching request while a fresh result is generated in the background
      (#94694). The reference page only described production, where results
      are not stored across requests, so a reload in dev that showed the
      previous result looked like a bug. This adds one sentence describing the
      dev behavior.
      
      Finding: https://next-maintainer-agent.vercel.tools/agent-feedback/2068
      
      <!-- NEXT_JS_LLM -->
      45e09fa4
    • Niklas Mischkulnig's avatar
      test: unskip tests for Turbopack (#100185) · 9b87239c
      Niklas Mischkulnig authored
      - Run three more test suites with Turbopack as well
      - Delete test/production/typescript-custom-tsconfig. It was only
      checking stdout (and not actual behavior), and we have multiple other
      tests for `nextConfig.tsconfigPath` anyway: test/e2e/tsconfig-path,
      test/e2e/typescript-custom-tsconfig,
      test/production/app-dir/typescript-cli
      9b87239c
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.14 · 943f3a40
      next-js-bot[bot] authored
      943f3a40
    • next-js-bot[bot]'s avatar
    • Niklas Mischkulnig's avatar
      chore: fix turborepo cache for miri unit test job (#100241) · 3f1cd37e
      Niklas Mischkulnig authored
      Fix
      ```
      Run vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10
      Exchange GitHub OIDC token for Vercel access token
        Error: OIDC environment variables are missing. The calling job needs "permissions: id-token: write".
        Error: Process completed with exit code 1.
      ```
      3f1cd37e
    • Niklas Mischkulnig's avatar
      Fix binary trace self-time on same-span re-entry (#100205) · db973dc7
      Niklas Mischkulnig authored
      ## Summary
      
      Fix lost binary-trace self-time when a span re-enters itself on the same
      thread, as happens with instrumented futures. Previously, the inner Exit
      restarted the outer frame's clock under the same `(span_id, thread_id)`
      key and immediately removed it, dropping the outer frame's remaining
      work.
      
      Store the active slice start on each per-thread stack frame instead.
      Enter closes the current top's slice; Exit closes the matching frame and
      resumes the new top only when the exiting frame was on top. Non-LIFO
      exits remove suspended frames without restarting another clock;
      unmatched exits leave clocks unchanged. Allocation attribution,
      queued-parent processing, and `DROP_SPANS` remain intact.
      
      **Binary flame CPU/self-time, concurrency-corrected time, and
      concurrency metrics will change because the previously missing slices
      are now accounted for correctly.** This does not change the binary trace
      format.
      
      Add encoded `TraceRow` parser regressions for single/multiple same-span
      nesting, child interleaving, cross-thread activity, non-LIFO/unmatched
      exits, live input with a partial final row, allocations, queued parents,
      and dropped spans. Five regression cases failed against the original
      reader before the fix.
      
      ## Verification
      
      - `cargo test -p turbopack-trace-server` — 84 library and 58 binary
      tests passed.
      - `cargo clippy -p turbopack-trace-server --all-targets -- -D warnings`
      — passed.
      - `cargo fmt --all -- --check` — passed.
      - Generated a real binary trace from a small local app using published
      `16.5.0-canary.10` with `NEXT_TURBOPACK_TRACING=turbo-tasks`: 2,282,825
      rows, 652,508 Enter/Exit pairs, 11 threads, and 109,050 same-span
      re-entries; all exits LIFO.
      - Independently decoded the raw postcard rows with a standalone decoder
      and reconstructed slices using per-thread span-ID stacks and transition
      timestamps. Of 1,118,980 physical positive frame slices, five were
      intentionally excluded by existing thread/blocking-span rules. The
      remaining **1,118,975-slice multiset matched exactly** in both Store
      events and `self_time_tree`, including ownership and start/end
      timestamps. Independent self-time, stored self-time, and root flame CPU
      total all equaled **11.537977 CPU seconds**. No trace payload or local
      app files are included.
      - Repository-wide `pnpm build-all` bootstrap could not start because
      this checkout has no `node_modules` (`turbo: command not found`); the
      Rust checks above ran successfully.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 8e507624-bae8-4561-8469-867912a2654e -->
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      db973dc7
    • Yousef Dawood's avatar
      docs: add instant navigation testing to Playwright guide (#100003) · a73eee23
      Yousef Dawood authored
      ### What?
      
      Adds a "Testing instant navigations" section to the Playwright guide. It
      covers the `instant()` helper from `@next/playwright`: how to install
      it,
      an example test, and how to enable the testing API when running tests
      against a production build.
      
      ### Why?
      
      The `instant()` helper is documented in the Instant navigation guide and
      the `instant` API reference, but the Playwright guide never mentions it.
      People who come to this page to learn how to test Next.js apps with
      Playwright won't find out that a helper exists for catching regressions
      in
      instant navigations.
      
      ### How?
      
      - Adds a new section at the end of the Playwright guide, wrapped in
        `<AppOnly>` because the feature requires Cache Components.
      - Includes the install command, an example test using `instant()` with
        `page.waitForURL()`, a note about passing `baseURL`, and the
        `exposeTestingApiInProductionBuild` config for production builds.
      - Content is based on the existing official docs:
        - https://nextjs.org/docs/app/guides/instant-navigation
      -
      https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/instant
      -
      https://nextjs.org/docs/app/api-reference/config/next-config-js/exposeTestingApiInProductionBuild
      a73eee23
    • Joseph's avatar
      docs: type error.js error prop as unknown (#100232) · ae63c57a
      Joseph authored
      ## Summary
      
      Follow-up to #100196. `error.js` and `global-error.js` receive whatever
      was thrown: Server Component errors arrive as an `Error`, but a value
      thrown in a Client Component is passed through as-is. The docs annotated
      the prop as `Error & { digest?: string }` and described it as always an
      `Error`.
      
      - `error.mdx` and Getting Started > Error Handling: type `error` as
      `unknown` in the `error.tsx` and `global-error.tsx` examples, and
      describe the prop as the thrown value, with a note to narrow before
      reading `message` or `digest`.
      - `with-stripe-typescript`: the three `error.tsx` boundaries narrow with
      `instanceof Error`. The component is renamed from `Error` to `ErrorPage`
      so it no longer shadows the global.
      
      <!-- NEXT_JS_LLM -->
      ae63c57a
    • next-js-bot[bot]'s avatar
      v16.5.0-canary.13 · 8e870bc4
      next-js-bot[bot] authored
      8e870bc4
    • Tobias Koppers's avatar
      next-api: isolate dropped entrypoint collectibles in an inner operation (#100187) · 7211bfcc
      Tobias Koppers authored
      > [!NOTE]
      > Stacked on #100165. Compare against
      `codex/net-collectibles-in-from-task`.
      
      ### What?
      
      Split `entrypoints_without_collectibles_operation` into two root
      operations:
      
      - **`inner_entrypoints_without_collectibles_operation`**, a function
      nested inside the outer operation, contains the previous body:
      `strongly_consistent` resolve, `drop_issues()`, `take_effects()`, then
      `connect()`. Its long name is kept so it is easy to identify in traces.
      - **`entrypoints_without_collectibles_operation`** keeps its name and
      signature, and only connects the inner operation.
      
      `EntrypointsOperation::new` and all `pick_*` operations are unchanged.
      
      ### Why?
      
      During `next build`, ~6,000 `pick_*` root operations connect to
      `entrypoints_without_collectibles_operation`.
      
      - **Problem:** that task drops the issues and takes the effects of the
      entrypoints subgraph. It therefore holds an own negative count for each
      of them alongside the positive aggregated counts. Each new `pick_*`
      upper receives a copy of all of those collectibles. #100165 nets them
      outside the follower lock, but the copy remains.
      - **Fix:** moving the drop/take into an inner root operation keeps those
      negative counts in the inner task. The outer task, which the `pick_*`
      roots connect to, should then have no (or only very few) collectibles to
      copy into each of them. This is reasoning from the code; I didn't
      measure the per-task collectible counts.
      
      ### How?
      
      **Measurement** against #100165 (`acba773c`):
      `bench/nested-deps-app-router-many-pages`, 32 CPUs, cold untraced `next
      build`, 1 warm-up plus 4 interleaved rounds per arm.
      
      | Metric | #100165 median | this PR median | median paired change |
      |---|---:|---:|---:|
      | `turbopack-emit` | 8.27 s | 5.24 s | **−37.5%** |
      | "Compiled in" | 29.85 s | 26.80 s | −10.2% |
      | wall | 50.51 s | 46.55 s | −7.9% |
      
      All three metrics were faster in all 4 rounds.
      
      **Equivalence with #100165:**
      - The `.next` output has the same file set. After normalizing build IDs
      and timings, only the known per-build random keys differ.
      - Warning and error fixtures produce identical normalized issue output.
      
      **Local checks:** `pnpm build-all` passes (18/18 tasks), as do
      `next-api` clippy with `-D warnings` and rustfmt.
      
      **Limitations:**
      - One VM and four rounds, with no significance test.
      - I didn't add a trace or a direct collectible-count probe.
      - I didn't test dev/HMR or incremental rebuilds locally.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet d8fee2f9-18db-4936-b59a-f8417b8f4bbc -->
      
      ---------
      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>
      7211bfcc
    • Tobias Koppers's avatar
      turbo-tasks-backend: optimize aggregated updates outside of the lock (#100165) · a71504e5
      Tobias Koppers authored
      ### What?
      
      Net the collectible counts of an `AggregatedDataUpdate` in a new
      `AggregatedDataUpdate::optimize()`, called after the follower task's
      lock has been released.
      
      ### Why?
      
      When an aggregating task gains (or loses) an upper,
      `AggregatedDataUpdate::from_task` builds an update from the task's own
      collectible counts plus `+1` for every positive aggregated collectible.
      
      - **Cancelling entries:** a task that takes or drops the collectibles of
      its subgraph holds an own `-1` for each of them, so most of those
      entries cancel out. An earlier large `next build` investigation found
      one such update with 106,268 entries, of which only 4 had a nonzero net
      count.
      - **Serialization:** in a large `next build`, ~6,000 uppers connect the
      same task. `from_task` runs while that follower's lock is held, so
      anything done per update while the lock is held serializes across all
      workers.
      - **Why the earlier version didn't help:** a previous version of this PR
      netted inside `from_task`, still under the lock. It didn't improve emit
      time.
      
      ### How?
      
      - **`from_task`:** back to its original form (own entries, then `+1` per
      positive aggregated entry). It keeps a `Vec::with_capacity` upper bound
      so the vector isn't reallocated while the task is locked.
      - **`optimize()`:** sums the collectible entries per collectible, drops
      zero sums, and keeps the dirty container update unchanged. It reuses the
      vector's allocation.
      - **Call sites:** `optimize()` is called right after the follower lock
      is dropped, at the sites that apply the update to uppers afterwards.
      These are the new-follower paths and the lost-follower paths. In the
      lost-follower paths, `invert()` also moved out of the lock, after
      `optimize()`. The `balance_edge` paths, which hold both locks through
      `apply`, are unchanged.
      - **Semantics:** applying the optimized update (or its inversion) gives
      the same final counts in the upper, and the same set of collectibles
      whose presence changes. Intermediate flips within one update can be
      skipped. Result order is unspecified.
      
      **Tests:**
      - Unit tests for summing, cancellation, mixed counts, empty and single
      entries, and disjoint keys.
      - Equivalence of final counts and presence changes for add and invert.
      - The real `optimize().invert()` path on `CollectibleRef`s, including
      the dirty container update.
      - An integration test that reads an operation which takes its child's
      collectibles, through several root uppers.
      
      **Measurement** on canary `8521c6ae`
      (`bench/nested-deps-app-router-many-pages`, 32 CPUs, cold untraced
      builds, 1 warm-up plus 4 interleaved rounds, median of the paired
      per-round changes vs canary):
      
      | | change |
      |---|---:|
      | `turbopack-emit` | **−32.2%** (17.4 s → 11.9 s) |
      | "Compiled in" | −11.2% |
      | wall | −10.0% |
      
      All three were faster in all 4 rounds. Output (`.next` file set) and
      issues are unchanged vs canary. This is one VM and 4 rounds, and the
      gain isn't broken down between the preallocation and moving work out of
      the lock.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet d8fee2f9-18db-4936-b59a-f8417b8f4bbc -->
      
      ---------
      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>
      a71504e5
    • Andrew Imm's avatar
      Fix extensionless Google font URLs in both bundlers (#100158) · 98a73ead
      Andrew Imm authored
      Fixes #99114 in both Turbopack and Webpack
      
      Due to Google Fonts dynamically returning the "best" font for the UA, it
      sometimes comes back as WOFF2 without an extension. We hardcode an
      extension expectation, so this fails:
      
      Webpack assumed every font URL ended in an extension, causing a
      null-regex crash.
      Turbopack split JSON options at embedded `&` characters. After that, its
      extension check would also fail
      
      The solution:
      For Webpack, remove the unsafe dereference, and resolve the extension
      from the CSS `format('XYZ')` hint when the URL lacks an extension
      
      For Turbopack, carry the resolved font extension from CSS extraction
      into asset emission instead of requiring a URL suffix.
      
      Also while investigating, Fleet found another bug: it parses the
      serialized options as a query string, so embedded `&` characters split
      the options before it ever reaches the extension check. To fix, we now
      percent-encode the entire JSON as one query entry, preserving the
      embedded params.
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarAndrew Imm <494043+andrewimm@users.noreply.github.com>
      Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
      98a73ead
    • Tobias Koppers's avatar
      Emit the Turbopack shared-runtime bootstrap in the PPR resume so it gets the CSP nonce (#100102) · 6dda4371
      Tobias Koppers authored
      ### What?
      
      With `cacheComponents` and the default
      `experimental.turbopackSharedRuntime`, a Turbopack production build
      breaks hydration under a nonce-based CSP (`script-src 'self'
      'nonce-…'`). The route's inlined chunk-group bootstrap ends up in the
      prerendered static shell without a nonce. The browser blocks it, the
      Turbopack runtime never starts the entry, and the page stays
      non-interactive.
      
      This PR emits that bootstrap from the per-request part of the response
      instead, where the request's nonce is known. The shared runtime stays on
      by default.
      
      ### Why?
      
      Since 16.4 the shared runtime replaces the per-route evaluate chunk with
      an inline `globalThis.TURBOPACK.push({ otherChunks, runtimeModuleIds })`
      script, passed to React as `bootstrapScriptContent`. A PPR static shell
      is rendered at build time: there is no request, so React has no nonce to
      put on it.
      
      The shell can't be fixed when it's served either. On Vercel the proxy
      serves the cached shell before any Next.js code runs, and only the
      resumed dynamic stream is rendered per request. So the bootstrap has to
      come from that stream.
      
      ### How?
      
      **Server.** Cache Components prerenders now keep the Turbopack bootstrap
      separate from the other bootstrap content, such as the Instant
      Navigation testing script, and leave it out of the shell.
      - For a postponed shell, the resume emits it as an inline script with
      the request nonce, right before the inlined Flight data. This reuses the
      existing data-injection pipeline, so the ordering is the same as today:
      after the first HTML chunk for empty preludes, and for HTML- and
      data-postponed state on both the Node and web stream paths.
      - A complete prerender emits it the same way, as part of the stored
      response.
      - Fully dynamic renders and non-Cache-Components prerenders keep using
      React's `bootstrapScriptContent`.
      - The paths that serve a postponed shell without a resume (the Instant
      Navigation testing lock and `__nextppronly` shell debugging) append the
      bootstrap themselves.
      
      **Client.** A bootstrap pushed after the shared runtime has loaded is
      registered from inside that inline script. There,
      `document.currentScript` has no `src`, so `appBootstrap()` threw
      `Invalid URL` while deriving the asset prefix. That prefix is only used
      by the dev server's HMR WebSocket, so it's now only derived on the dev
      server. Dev behavior is unchanged.
      
      **Not covered:**
      - React's own `$RT` timing script in the static shell still has no
      nonce, so a nonce CSP still reports that one violation. It doesn't
      affect hydration, and it was already blocked before 16.4.
      - Fully static pages under a nonce CSP are unchanged; their inline
      Flight data has no nonce either.
      
      ### Tests
      
      New e2e suite `test/e2e/app-dir/ppr-shared-runtime-csp-nonce`. It runs
      on Turbopack production builds only (`@force-gate !dev && turbopack`)
      and covers:
      - the shell contains no bootstrap, and the resume contains it exactly
      once with the request nonce
      - the nonce is also picked up from a report-only CSP, and there is no
      nonce without a CSP
      - the page hydrates under a nonce CSP
      - the page hydrates when the bootstrap runs after the shared runtime and
      all entry chunks have loaded. The test forces that ordering
      deterministically, and it fails without the client change.
      - fully static pages keep the inline bootstrap and hydrate
      
      It fails on `canary` because the bootstrap is in the shell without a
      nonce and the page doesn't hydrate.
      
      Existing suites run to check behavior didn't change:
      - Turbopack start: `instant-navigation-testing-api` (this suite caught
      the late-bootstrap `Invalid URL` issue), `ppr-partial-hydration`,
      `partial-fallback-root-blocking`, `partial-fallback-shell-upgrade`,
      `csp-nonce-segment-scripts`, `next-dynamic-csp-nonce`,
      `static-shell-debugging`
      - Webpack start: `csp-nonce-segment-scripts`
      - Dev (Turbopack): `csp-nonce-segment-scripts`
      
      I also checked by hand with the issue's reproduction (nonce CSP from
      `proxy.ts`): the page hydrates and only the `$RT` violation remains.
      
      Not run: Vercel deploy and edge-runtime tests.
      
      Fixes #99800
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 551793ce-4e56-41fa-ab7b-183f9c45ac27 -->
      
      ---------
      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>
      6dda4371
    • Tobias Koppers's avatar
      Keep requests through middleware in a single OpenTelemetry trace (#100136) · 2e559938
      Tobias Koppers authored
      ### What?
      
      Requests that pass through middleware / `proxy.ts` now produce **one
      OpenTelemetry trace**, instead of two or three.
      
      Before, with OTEL configured in `instrumentation.ts`:
      
      | Request | No outer span | With an outer span (APM, custom server) |
      |---|---|---|
      | Middleware continues to render (`next()` / rewrite) | 3 traces (2
      before 16.3) | 2 traces (1 before 16.3) |
      | Middleware redirect / direct response | 2 traces (1 before 16.3) | 2
      traces (1 before 16.3) |
      
      After: 1 trace in every case.
      
      ### Why?
      
      Two independent causes:
      
      1. **Long-standing (13.5 → canary), #91282.** When middleware lets a
      request continue, the router server runs `BaseServer.handleRequest`
      twice: a middleware-invoke pass, then a render pass. Each pass extracts
      its context from the incoming request headers. Without an incoming
      `traceparent`, each pass started its own root trace.
      2. **16.3 regression from #95306.** In-process Node.js middleware ran
      under `ROOT_CONTEXT` to make `Middleware.execute` a sibling of
      `handleRequest`. That also detached it from any outer span, so the
      middleware span always started an extra trace.
      
      Customers upgrading 16.2 → 16.3 see this as "doubled traces".
      
      ### How?
      
      When middleware lets a request continue, the render is always **nested
      inside the middleware span**, in every host:
      
      ```
      next start / next dev:
       handleRequest GET (bubble, root)
        └─ middleware GET
            └─ GET /page
      
      separately-invoked middleware (Vercel, adapters, direct entrypoints), no parent:
       middleware GET (root)
        └─ GET /page
      
      host span / incoming traceparent P:
       P
        └─ middleware GET            (next start: P → handleRequest GET → middleware GET)
            └─ GET /page
      ```
      
      **Middleware → render.** The middleware adapter forwards the
      `Middleware.execute` span's own W3C context (`traceparent` /
      `tracestate`, via the configured propagator) as request-header overrides
      on `next()` and rewrite responses. Every host already applies these
      overrides to the downstream request, including the `next start` router
      server, so no new host protocol is needed.
      - Override lists replace the whole downstream header set. So:
      - **No user overrides:** the adapter lists every request header the
      middleware received, plus the trace headers.
      - **User overrides present:** they are kept, and the trace headers are
      added.
      - **User-set trace headers:** a `traceparent` / `tracestate` the
      middleware explicitly set (different from the one it received) wins. A
      value copied unchanged from the request, as with `new
      Headers(request.headers)`, is replaced so the render still nests.
      - Redirects and direct responses are untouched.
      
      **Request → middleware (self-hosted).** Once the middleware-invoke
      pass's `handleRequest` span is active, its W3C context is written onto
      the request headers. The middleware adapter (Node.js and the Edge
      sandbox) extracts it, so the middleware span is a child of that pass.
      The middleware-pass span keeps its existing name (`GET`); the route
      stays on the render-pass span. If there is no middleware span to forward
      (for example OTEL is registered only for Node.js while middleware runs
      on Edge), the render falls back to this context and still stays in one
      trace.
      
      **#95306 regression.** The `ROOT_CONTEXT` detachment is removed, so an
      outer span, an incoming `traceparent`, or the middleware-pass span now
      parents Node.js middleware normally.
      
      All of this only runs when OpenTelemetry is active and a valid span
      context exists. Without OTEL, no headers are added.
      
      One-time initialization traces stay separate by design: instrumentation
      registration, route-module prewarming, and the once-per-process lazy
      `RouteModule.prepare` of direct entrypoints.
      
      ### Tests
      
      - **New deploy-capable suite
      `test/e2e/app-dir/otel-middleware-single-trace`.** It runs Node.js
      `proxy.ts` and Edge `middleware.ts` with `@vercel/otel`. Middleware
      reports its active trace and span IDs; the render reports its active
      trace ID and the `traceparent` it received. The test asserts one trace
      and that the render's parent is the middleware span, so no collector is
      needed. It runs in dev, start and deploy mode, with no deploy gate. It
      covers:
      - continue to a page and to a route handler, plus rewrite, redirect and
      a direct response;
      - a request the middleware doesn't match, and an incoming `traceparent`;
      - user header overrides, including a deletion (the render still nests),
      and a user-set `traceparent`;
        - no internal `x-middleware-*` headers reaching the client.
      - **Existing collector suite `test/e2e/opentelemetry/instrumentation`.**
      The middleware tests now assert **real** trace IDs and the exact shape:
      the render span's parent is the middleware span, the middleware span's
      parent is the middleware-pass `handleRequest` (self-hosted) or the
      external / host parent. They also check every span exported for the
      request.
      - **Setups:** default and direct-entrypoint hosting; Edge and Node.js
      middleware; root context and incoming `traceparent`.
        - **Requests:** page, route handler, rewrite and redirect.
        - **New variant:** direct entrypoints with a host parent span.
      - **Unit tests** for the override helper
      (`forward-trace-context.test.ts`), including unchanged copied trace
      headers.
      
      ### Verification
      
      - The new suite's nesting checks and the collector shape checks fail
      before this change (render parented to `handleRequest` or the external
      span) and pass after it.
      - New suite passes in dev (Turbopack), start (Turbopack, webpack), and
      the same with `__NEXT_CACHE_COMPONENTS=true`.
      - Full `test/e2e/opentelemetry/instrumentation/` passes in start mode
      (Turbopack); the middleware tests also pass in dev (Turbopack) and start
      (webpack).
      - Passed on the previous revision (not re-run for the nesting change):
      `test/e2e/opentelemetry/client-trace-metadata`,
      `test/e2e/app-dir/otel-parent-span-propagation`,
      `test/e2e/middleware-request-header-overrides`, and the W3C trace-header
      fetch-cache test in `test/e2e/app-dir/app-static`.
      - Deploy: an earlier revision's trace-ID assertions passed on Vercel
      (default and Cache Components). The new parent-span assertion runs on
      Vercel for the first time in this revision's CI.
      
      Fixes #91282
      
      <!-- 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>
      2e559938
    • Tobias Koppers's avatar
      Write webpack dev manifests atomically (#100112) · a5fe506d
      Tobias Koppers authored
      ### What?
      
      In webpack dev, manifest files (`*manifest.json` / `*manifest.js`, e.g.
      `next-font-manifest.json` and `page_client-reference-manifest.js`) are
      now written atomically: the content goes to a temp file next to the
      manifest, which is then renamed over it. Other emitted assets are
      written as before.
      
      ### Why?
      
      This fixes a canary hard flake in `test/e2e/app-dir/not-found/basic` ›
      "should render the 404 page when the file is removed, and restore the
      page when re-added"
      ([example](https://github.com/vercel/next.js/actions/runs/38003705301/job/114068060547)).
      It is a real dev-server bug:
      
      - Renaming `app/page.js` away makes `/` render `/_not-found`. That entry
      is already built, so the render doesn't wait for the in-flight rebuild.
      - Webpack writes emitted assets in place (it truncates first).
      `RouteModule.loadManifests` can therefore read a 0-byte manifest.
      Instrumented local runs caught
      `.next/dev/server/app/_not-found/page_client-reference-manifest.js`
      (`Manifest file is empty`) and
      `.next/dev/server/next-font-manifest.json` (`Unexpected end of JSON
      input`). CI shows the same errors on every retry.
      - The request returns a 500, the browser lands on the pages error page,
      which never recovers through app-dir HMR, and the test times out after
      120 s.
      
      Turbopack already writes its manifests with `writeFileAtomic` and isn't
      affected.
      
      ### How?
      
      - `createAtomicManifestOutputFileSystem(fs)` returns an output FS that
      inherits from webpack's shared `graceful-fs` object without mutating it.
      Manifest writes go through the existing sync `writeFileAtomic` helper
      (`lib/fs/write-atomic.ts`, now accepting `Buffer`). That helper is the
      same one Turbopack's manifests use, and it already handles temp naming,
      cleanup and the Windows-tolerant `renameSync`. All other writes and
      methods go to the original FS.
      - One wrapped FS is created next to the shared `inputFileSystem` and
      assigned to every compiler in the multi-compiler. The fallback compiler
      is wrapped too.
      - This assumes the disk-backed dev output that Next.js uses. The dev
      server reads these manifests from disk with Node `fs` anyway.
      
      ### Verification
      
      Full test file, `pnpm test-dev-webpack`, CI env
      (`NEXT_TEST_REACT_VERSION=18.3.1`,
      `__NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true`):
      
      | | Runs | Manifest read errors | Failures |
      |---|---|---|---|
      | canary | 8 | 5 | 5 |
      | this PR | 10 | 0 | 2* |
      
      \* Both remaining failures happened at the *restore* step: an HMR
      refresh arrived before the app router initialized. That's a separate
      root cause, fixed independently in #100113, and with both PRs applied
      the file passed 10/10.
      
      - `pnpm test-dev-turbo`: 3/3 passed. `pnpm test-start-webpack`: passed.
      - After the switch to `writeFileAtomic`, with #100113's fix applied: 5/5
      full-file `pnpm test-dev-webpack` runs passed in the same CI env, with
      no manifest read errors.
      - Unit tests run against a real temp dir. They cover Buffer bytes being
      preserved and the target keeping its complete old content at the rename
      boundary (then the complete new one). They also cover errors reaching
      the callback exactly once, no leftover temp files, delegation of
      non-manifest writes, and the original FS not being mutated.
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet e9d6c475-aeff-42d9-a058-210b6631f951 -->
      
      ---------
      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>
      a5fe506d