1. 17 Aug, 2026 7 commits
    • next-js-bot[bot]'s avatar
      v16.3.1-canary.22 · 6be68703
      next-js-bot[bot] authored
      6be68703
    • hardfist's avatar
      fix(turbo-persistence): allow 32-bit usize conversion (#97288) · 9e1dc0eb
      hardfist authored
      ### What?
      
      Change the pointer-width assertion in `usize_from_u32` from `<` to `<=`,
      allowing the conversion to compile on 32-bit targets.
      
      ### Why?
      
      The surrounding comment states that Turbopack assumes a pointer width of
      at least 32 bits, but the strict comparison rejects exactly 32-bit
      targets. Since `u32` and `usize` have the same width on these targets,
      the conversion remains lossless.
      
      This currently causes `rspack-turbo-persistence` to fail to compile with
      `error[E0080]` in Rspack's [`i686-pc-windows-msvc` CI
      job](https://github.com/web-infra-dev/rspack/actions/runs/31665978273/job/94340544786#step:25:446).
      
      ### How?
      
      Allow equal source and target bit widths in the compile-time assertion.
      9e1dc0eb
    • Niklas Mischkulnig's avatar
      test: restore missing NFT `exports*` unit fixtures (#97459) · d8234277
      Niklas Mischkulnig authored
      ### What?
      
      Restores the missing `node_modules` fixtures for the `exports`,
      `exports-fallback`,
      `exports-only` and `exports-path` cases in `turbopack-tracing`'s NFT
      unit test suite
      (`tests/unit.rs`), and enables the two that pass as-is (`exports-only`,
      `exports-path`).
      Co-authored-by: 's avatarvercel-fleet[bot] <308483924+vercel-fleet[bot]@users.noreply.github.com>
      d8234277
    • Zack Tanner's avatar
      [ci] Fix backport canary release dispatch (#97383) · 10439f3c
      Zack Tanner authored
      ## Summary
      
      - Use the job-scoped `GITHUB_TOKEN` with explicit `actions: write`
      permission to dispatch `trigger_release.yml` after a stable backport.
      - Avoid requesting Actions write access from the release GitHub App,
      which currently prevents the dispatch token from being created.
      - Preserve the existing forced preminor canary release behavior.
      
      This fixes the failure that left canary semver-behind stable after the
      `v16.3.1` backport. The evaluation succeeded, but the dispatch failed
      while creating the App token in the [failing dispatch
      job](https://github.com/vercel/next.js/actions/runs/31750536217/job/94615208366).
      
      ## Verification
      
      https://github.com/vercel/next.js/actions/runs/31830288265/job/94864091005
      ```
      should_dispatch=true
      reason=Dispatching canary preminor release because stable release 16.3.1 is ahead of 16.3.1-canary.17
      released_version=16.3.1
      current_canary_version=16.3.1-canary.17
      dispatch_input=false
      auto_dispatch_enabled=true
      ```
      10439f3c
    • Luke Sandberg's avatar
      turbo-tasks-backend: Enforce that tasks exist when accessing them (#96043) · 1c50e09d
      Luke Sandberg authored
      Change the semantics of `task` so that it enforces that tasks actually
      exist (either in memory or storage). For the rare cases we expect to be
      creating tasks, have callers call `get_or_create_task`
      
      generally creating a task is _racy_ so it is always `get_or_create` but
      when doing things like updating the aggregation graph or reading cells,
      we _know_ it must exist so assert it.
      
      Currently this is a `debug_assert` but with the GC we may update it to a
      full assert.
      
      ---------
      Co-authored-by: 's avatarClaude Opus 4.8 (1M context) <noreply@anthropic.com>
      1c50e09d
    • Luke Sandberg's avatar
      turbo-tasks-backend: add persistence delete/tombstone plumbing for GC (#95975) · 8a473f45
      Luke Sandberg authored
      ## What
      
      The persistence-layer mechanism to tombstone (delete) tasks from the
      on-disk cache. A GC-collected task is represented as a
      `SnapshotItem::Delete` that rides the same streaming iterator
      `save_snapshot` already consumes for puts, so tombstones are applied in
      the same commit/batch as the snapshot with no side-channel.
      
      - `SnapshotItem` becomes an enum: `Put { … }` (the existing path) and
      `Delete(TaskDeletion)`.
      - `TurboWriteBatch::delete/value_delete` passthrough to
      `turbo_persistence`.
      - `save_snapshot` applies deletes inline in the parallel put phase
      
      
      ## Note
      
      `SnapshotItem::Delete` is `#[allow(dead_code)]` here: this PR lands the
      persistence-side *handling* and its tests, but nothing *emits* a
      `Delete` yet. The GC pass that soft-deletes tasks and serializes them to
      `Delete` lands in the next PR in the stack. So this PR is a no-op at
      runtime.
      
      ---------
      Co-authored-by: 's avatarClaude Opus 4.8 (1M context) <noreply@anthropic.com>
      8a473f45
    • Luke Sandberg's avatar
      turbo-persistence: add key-value tombstones for MultiValue families (#96929) · 863a0ada
      Luke Sandberg authored
      Add a new `tombstone` format to the persistence layer so we can delete
      key-value pairs out of MultiValued tables
      
      This is in service of the upcoming GC support, but also fills a basic
      API gap in the db.
      
      To delete a key-value-pair you need to call `value_delete` and currently
      the values are limited to only those that are able to be stored inline
      in key blocks. This is a non-trivial limitation but it fits our current
      usecase, and makes the compaction/query algorithms a bit simpler (don't
      need to 'resolve' values)
      
      One non-trivial complexity was maintaining the 'FixedLayout' block
      optimization for a mix of tombstones and values, so now we support a
      slightly different mode where all keys have the same length but possibly
      different types.
      
      Finally, this branch solves a problem with deleting tombstones.
      Tombstones 'shadow' older values and allow us to drop them during
      compaction. With GC getting ready to start writing tombstones the risk
      becomes 'when can we delete a tombstone! This is solved
      probabilistically using the amqf filters, during compaction we drop
      tombstones if they could not possibly match anything in an older SST.
      Without this, tombstones in the TaskCache table would fill up over time.
      863a0ada
  2. 16 Aug, 2026 5 commits
    • next-js-bot[bot]'s avatar
      v16.3.1-canary.21 · d45672c0
      next-js-bot[bot] authored
      d45672c0
    • Hendrik Liebau's avatar
    • Josh Story's avatar
      test: deflake use-cache-size-zero warm reload (#97421) · c18acf5c
      Josh Story authored
      ## Summary
      
      Keep the first warm reload assertion focused on browser-visible
      stale-while-revalidate behavior, then poll the route with independent
      HTTP requests until a later response observes the fresh value. After
      convergence, perform one final browser reload to confirm the
      user-visible path also receives an updated value.
      
      This avoids fixed delays, cache debug logging, and repeated browser
      navigations that can cancel or outpace background regeneration. The
      convergence poll uses the standard 3-second `retry()` window and returns
      as soon as freshness is observed; the browser only reloads again after
      that condition is satisfied.
      
      ## Verification
      
      - `__NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true NEXT_TEST_CI=true
      HEADLESS=true pnpm test-dev-webpack
      test/development/app-dir/use-cache-size-zero/use-cache-size-zero.test.ts`
      - `__NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true NEXT_TEST_CI=true
      HEADLESS=true pnpm test-dev-turbo
      test/development/app-dir/use-cache-size-zero/use-cache-size-zero.test.ts`
      
      <!-- NEXT_JS_LLM -->
      c18acf5c
    • Andrew Clark's avatar
      Scaffolding for concurrentRouterQueue flag (#97413) · dd76599c
      Andrew Clark authored
      Sets up the scaffolding for a rewrite of the client router's queue.
      
      I've named the new module concurrent-router-queue.ts and the existing
      module sequential-router-queue.ts, since the main goal of the new one is
      to improve the router's integration with React's concurrent rendering
      model. The experimental flag is likewise named `concurrentRouterQueue`.
      
      There's no implementation yet; all router operations throw an error when
      the flag is enabled.
      
      The main entry point into the router is navigator.ts. The flag swaps
      between implementations at the module level to ensure the inactive code
      is eliminated from the final bundle.
      dd76599c
    • Andrew Clark's avatar
      Reorganize client router modules (#97402) · 5a3a3d19
      Andrew Clark authored
      Pure structural refactor, no behavior changes.
      
      This continues some of the clean-up work I've been doing in the client
      router now that more of the implementation has settled, post-Segment
      Cache and Instant Navigations.
      
      I have two primary motivations here. The first is purely
      maintainability. The current module structure is a mess, and the naming
      is misleading when browsing the codebase for the first time.
      
      The second motivation is to prepare for an upcoming rewrite of the
      router queue. There will likely be two simultaneous implementations for
      a while as the new one settles, so it's extra important the interface
      into the router queue is well-defined. I want the fork between the two
      worlds to be as clean as possible. This is a similar approach to the one
      I took when rewriting the prefetching implementation.
      
      Some of the key name changes:
      
      - ppr-navigations.ts → render-tree.ts. This module's responsibility is
      to create the tree that gets passed into React for rendering, currently
      called the CacheNode tree. I considered renaming it to cache-node.ts,
      but I kept it more generic because I have plans to refactor that type
      soon.
      - segment-cache/navigation.ts → app-router-state.ts. This module's
      responsibility is to compute the next AppRouterState given inputs. It
      does perform network requests, but it's conceptually a "pure" operation.
      It doesn't deal with any of the router queueing logic. This is the most
      reducer-y of the code that still exists, and along with render-tree.ts,
      it will remain mostly shared between the old and new state machine
      implementations.
      - navigator.ts. This is a new module I created to act as the single
      entry point for router-level operations: push, replace, navigate,
      traverse, restore, refresh, hmrRefresh. This is the primary place where
      we'll fork the old and new queue implementations. It's also how we'll
      ensure the inactive implementation gets dead-code-eliminated properly
      while the two implementations live side-by-side.
      5a3a3d19
  3. 15 Aug, 2026 6 commits
    • next-js-bot[bot]'s avatar
      v16.3.1-canary.20 · d1aeb1ce
      next-js-bot[bot] authored
      d1aeb1ce
    • dan's avatar
      Wait for back-before-hydration recoveries in the browser (#97321) · 2fbeebba
      dan authored
      The `back-before-hydration` assertions read the heading with
      `browser.elementByCss`, which waits for the load event before it
      returns. Here the load event cannot fire until the stalled scripts are
      released and finish running, and that is the whole window the test is
      about. So the first attempt inside `retry` blocks for almost the entire
      3s budget, looks at the DOM once, and then `retry` refuses a second look
      because `waited + interval > duration`.
      
      This waits in the browser instead, with the load event out of the
      picture. Every page already has its own heading id, except the two
      search pages, which shared one; they get a per-page id too. Then a
      single `waitForSelector` resolves the moment that page commits, and the
      URL assertion follows the wait rather than racing alongside it. The
      assertions that check content *stayed* put keep polling with `retry`,
      since a change there is the failure.
      
      Holding the flight response for 1800ms and throttling the renderer 8x
      reproduces the CI failure exactly on canary — same `Failed to retry
      within 3000ms`, same expected "Home" / received "Post" — and passes with
      this change; the suite is still 16/16 with the response held for 6s.
      
      Test-only.
      Co-authored-by: 's avatarClaude Fable 5 <noreply@anthropic.com>
      2fbeebba
    • Josh Story's avatar
      Extract metadata resolution primitives (#97388) · 6d0379d4
      Josh Story authored
      ## Summary
      
      The existing metadata resolver combines two responsibilities: walking
      the loader tree to collect and schedule route exports, and interpreting
      the metadata or viewport value produced by an individual route layer.
      
      Move the route-layer operations into metadata-resolution-primitives.ts.
      This includes wrapping generateMetadata and generateViewport, loading
      file-based metadata, merging values with their resolved parents,
      post-processing metadata, and producing SelectedMetadata for rendering.
      
      Keep resolve-metadata.ts responsible for the existing traversal and
      scheduling flow, importing the extracted operations back into the same
      call sites and preserving its existing exports. This creates a reusable
      boundary for other traversal strategies without introducing another
      resolution path.
      
      This is intended to be behavior preserving: traversal order, eager
      generator invocation, parent promise behavior, warnings, and rendered
      metadata and viewport tags are unchanged.
      
      ## Verification
      
      - pnpm build-all
      
      <!-- NEXT_JS_LLM -->
      6d0379d4
    • Tim Neutkens's avatar
      b5538511
    • Niklas Mischkulnig's avatar
      Turbopack: retain conditions when replacing resolve request keys (#97372) · 904a4185
      Niklas Mischkulnig authored
      Closes https://github.com/vercel/next.js/issues/97358
      
      `ResolveResult::with_replaced_request_key` overwrote the `conditions` of
      every result key with the conditions of the replacement key (empty at
      all call sites). Those conditions are what distinguishes the results one
      request resolved to under different export conditions, so both the
      `module-sync` and the `default`/`require` target of the same subpath
      ended up under the same `RequestKey`.
      
      That is lossy as soon as a request resolves in more than one
      `node_modules` directory: the results are merged through a
      `RequestKey`-keyed map, so one of the two targets is silently dropped.
      With a single candidate directory `ResolveResult::alternatives`
      short-circuits and never builds that map, which is why this only showed
      up in nested layouts.
      
      In practice this broke `output: 'standalone'` with the Turbopack
      production bundler for pnpm installs, whose virtual store hoists every
      package into `node_modules/.pnpm/node_modules` and thereby creates that
      second candidate directory: `next-server.js.nft.json` recorded only
      `@swc/helpers/cjs/_interop_require_default.cjs`, while Node >= 22.12
      resolves `@swc/helpers/_/_interop_require_default` to the `module-sync`
      target `esm/_interop_require_default.js` (`@swc/helpers` 0.5.23 lists
      `module-sync` first). The copied `.next/standalone/server.js` then
      exited with MODULE_NOT_FOUND before listening.
      
      ---------
      Co-authored-by: 's avatarvercel-fleet[bot] <308483924+vercel-fleet[bot]@users.noreply.github.com>
      904a4185
    • Tim Neutkens's avatar
      Remove server route matcher stack (#94157) · 6b900193
      Tim Neutkens authored
      ### What?
      
      Remove the legacy server route matcher managers, route matcher
      providers, and server route matcher classes. Move route definition and
      params metadata into fsChecker output and request metadata instead.
      
      ### Why?
      
      The filesystem checker already owns the normalized route lookup path in
      production. Keeping a separate matcher manager stack duplicates route
      inventory, adds reload plumbing, and makes dev and production behavior
      harder to keep aligned.
      
      ### How?
      
      - Build pages and app route definitions in fsChecker from production
      manifests and from the dev route inventory.
      - Thread matched route definitions and params through resolve-routes and
      router-server request metadata into base-server and next-server.
      - Remove reloadMatchers propagation and delete the legacy matcher
      manager, provider, and matcher implementations and tests.
      - Preserve dev ensurePage behavior, including legacy custom-server
      render methods, and Pages API loading by using matched route definitions
      while loading compiled dev modules where needed.
      
      ### Verification
      
      - `pnpm test-start-webpack test/e2e/custom-routes/custom-routes.test.ts`
      - `pnpm test-start-turbo test/e2e/custom-routes/custom-routes.test.ts`
      - `pnpm test-dev-webpack test/e2e/custom-routes/custom-routes.test.ts`
      - `pnpm test-dev-turbo test/e2e/custom-routes/custom-routes.test.ts`
      - `pnpm test-dev-webpack
      test/e2e/on-request-error/dynamic-routes/dynamic-routes.test.ts`
      - `pnpm test-dev-turbo
      test/e2e/on-request-error/dynamic-routes/dynamic-routes.test.ts`
      - `pnpm test-start-webpack
      test/e2e/app-dir/app-routes/app-custom-routes.test.ts`
      - `pnpm test-start-webpack
      test/e2e/app-dir/edge-route-rewrite/edge-route-rewrite.test.ts`
      - `pnpm test-start-webpack
      test/e2e/middleware-rewrites/test/index.test.ts`
      - `pnpm test-start-webpack test/e2e/middleware-matcher/index.test.ts
      test/e2e/middleware-custom-matchers-basepath/test/index.test.ts
      test/e2e/app-dir/rewrites-redirects/rewrites-redirects.test.ts`
      - `pnpm test-start-webpack test/e2e/api-catch-all/api-catch-all.test.ts
      test/e2e/basepath-root-catch-all/basepath-root-catch-all.test.ts
      test/production/root-catchall-cache/root-catchall-cache.test.ts`
      - `pnpm test-start-webpack
      test/e2e/i18n-beforefiles-rewrite/i18n-beforefiles-rewrite.test.ts`
      - `pnpm test-start-webpack
      test/e2e/basepath/redirect-and-rewrite.test.ts`
      - `pnpm test-dev-webpack test/e2e/custom-server/custom-server.test.ts`
      - `pnpm test-start-webpack test/e2e/custom-server/custom-server.test.ts`
      - `pnpm --filter=next types`
      - `pnpm --filter=next build`
      - `git diff --check`
      
      <!-- NEXT_JS_LLM_PR -->
      6b900193
  4. 14 Aug, 2026 22 commits
    • next-js-bot[bot]'s avatar
      v16.3.1-canary.19 · 0d100b27
      next-js-bot[bot] authored
      0d100b27
    • Josh Story's avatar
      Adopt SelectedMetadata for metadata rendering (#97387) · ab8f4848
      Josh Story authored
      The metadata resolver currently passes ResolvedMetadata directly to tag
      rendering even though several fields only exist to carry state between
      route layers.
      
      Introduce SelectedMetadata as the post-processed, tag-ready
      representation and convert the current resolved output before rendering.
      This makes the final selection boundary explicit without changing
      generated tags, preparing the metadata pipeline for multiple
      independently resolved branches.
      
      <!-- NEXT_JS_LLM -->
      ab8f4848
    • Steven's avatar
    • Marcos Hernanz's avatar
      Turbopack: remove stale manifests for deleted routes (#97333) · ae0e0a50
      Marcos Hernanz authored
      ## What?
      
      - remove manifest fragments when Turbopack's development entrypoint
      cleanup removes a deleted page
      - add an end-to-end regression for replacing concrete App Router pages
      with an optional catch-all without restarting the dev server
      
      ## Why?
      
      Turbopack already removes deleted entry keys from its asset mapper,
      subscriptions, issues, and client state. It did not remove the
      corresponding records from `TurbopackManifestLoader`, so the next
      manifest write continued to serialize deleted App Router routes.
      
      When a deleted concrete route is replaced by an optional catch-all,
      those stale records conflict with the new route at the same specificity.
      The dev server reports the route conflict and responds with 404 until it
      is restarted.
      
      This is independently consistent with the cleanup identified in #97194.
      This draft adds end-to-end coverage that fails on current canary by
      observing both the 404 and stale manifest records, then passes with the
      lifecycle fix.
      
      ## How?
      
      Pass the existing manifest loader to `handleEntrypointsDevCleanup` and
      call its existing `delete(key)` method in the same branch that deletes
      the stale asset mapping. This keeps all per-entry manifest maps
      synchronized with the authoritative current entrypoint set without
      special-casing any route shape.
      
      The regression test:
      
      1. compiles two concrete localized routes
      2. deletes both pages and adds an optional catch-all
      3. waits for three affected paths to return the new catch-all content
      4. verifies the development app-paths manifest contains the catch-all
      and no deleted entries
      
      ## Verification
      
      - reproduced the report on `16.3.1-canary.10`: all four reported paths
      returned 404 after the live route replacement and returned 200 after a
      restart
      - confirmed the regression fails on current canary before the source
      change with the same-specificity route error and a 404 response
      - `pnpm test-dev-turbo
      test/development/app-dir/hmr-deleted-page/hmr-deleted-page.test.ts`
      - `pnpm test-dev-webpack
      test/development/app-dir/hmr-deleted-page/hmr-deleted-page.test.ts`
      - `pnpm test-dev-rspack
      test/development/app-dir/hmr-deleted-page/hmr-deleted-page.test.ts`
      - `CI=1 pnpm build-all`
      - `pnpm --filter=next build`
      - formatting, ESLint, staged-diff, and signed-commit checks
      
      Fixes #97035
      ae0e0a50
    • Niklas Mischkulnig's avatar
      Turbopack: make unreachable codegen more generic (#97385) · 1173626d
      Niklas Mischkulnig authored
      Make the inserted comment configurable.
      1173626d
    • next-js-bot[bot]'s avatar
      v16.3.1-canary.18 · 264e820e
      next-js-bot[bot] authored
      264e820e
    • next-js-bot[bot]'s avatar
    • next-js-bot[bot]'s avatar
      v16.3.1-canary.17 · 0f36a7df
      next-js-bot[bot] authored
      0f36a7df
    • Niklas Mischkulnig's avatar
      Turbopack: add imports_wildcard NFT unit test (#97373) · 278a8eae
      Niklas Mischkulnig authored
      Pull in test from https://github.com/vercel/nft/pull/604
      It was already passing
      278a8eae
    • Niklas Mischkulnig's avatar
      Turbopack: improve chunk_item_content docs (#97370) · ea223645
      Niklas Mischkulnig authored
      > for cache invalidation
      
      That was inaccurate.
      ea223645
    • Niklas Mischkulnig's avatar
      Turbopack: don't trace embedded WASM loader helpers (#97353) · a02b83fd
      Niklas Mischkulnig authored
      ### What?
      
      Turbopack's output-file tracer no longer fails the build when a Node.js
      App Route's server-external package graph reaches a `.wasm` file.
      
      ### Why?
      
      Since Turbopack still mapped `.wasm` / `.wat` to
      `ModuleType::WebAssembly`
      while tracing, the generated loader's embedded runtime helper
      (`[turbopack-wasm]/node/loadWasm.ts`) got pulled into the traced file
      list. `NftJsonAsset` only accepts paths under `[project]` or `[output]`,
      so it raised a fatal error and `next build` never finished.
      
      ### How?
      
      `turbopack/crates/turbopack/src/module_options/mod.rs`: map WASM sources
      to `ModuleType::Raw` when `analyze_mode == AnalyzeMode::Tracing`, the
      same
      way `.json` and `import … with { type: "text" | "bytes" }` are already
      handled for tracing. The real `.wasm` file keeps its filesystem path in
      the trace; no loader or embedded helper is created. Non-tracing bundling
      behavior is unchanged.
      
      Adds `test/production/turbopack-wasm-output-tracing/`, a production
      regression test that fails on the recorded baseline with
      
      NftJsonAsset: cannot handle filepath '[turbopack-wasm]/node/loadWasm.ts'
      
      and passes with the fix, asserting the embedded helper is absent from
      the
      route's `.nft.json` while the real `.wasm` file is still traced.
      
      
      Closes https://github.com/vercel/next.js/pull/97338
      Closes https://github.com/vercel/next.js/issues/96897Co-authored-by: 's avatarvercel-fleet[bot] <308483924+vercel-fleet[bot]@users.noreply.github.com>
      a02b83fd
    • Niklas Mischkulnig's avatar
    • David Alexandru Ilie's avatar
      Trace instrumentation startup (#97296) · 0311e143
      David Alexandru Ilie authored
      ## Summary
      
      - trace instrumentation module loading and `register()` execution as
      separate startup spans
      - preserve the original timestamps when the OpenTelemetry provider is
      installed by `register()` itself
      - export both lifecycle spans by default without attaching them to an
      unrelated request
      - verify standard and direct-entrypoint startup with a collector
      connected before the server starts
      
      ## Why
      
      Loading `instrumentation.ts` and running the user-defined `register()`
      hook have different owners and remediation paths. Separate spans make
      startup delays attributable while preserving honest lifecycle parentage:
      these spans normally occur before a request identity exists.
      
      ## Verification
      
      - `pnpm build-all`
      - `pnpm --filter=next build`
      - `pnpm --filter=next types`
      - `pnpm exec jest packages/next/src/server/lib/trace/tracer.test.ts
      --runInBand`
      - focused instrumentation-startup E2E in development and production with
      Turbopack and Webpack
      - Prettier, ESLint, and `git diff --check`
      
      ## Stack
      
      Depends on **Trace route module preparation**.
      0311e143
    • David Alexandru Ilie's avatar
      Trace route module preparation (#97295) · 44103a87
      David Alexandru Ilie authored
      ## Summary
      
      - trace the full route-module preparation boundary as
      `RouteModule.prepare`
      - record manifest loading as one aggregate `RouteModule.loadManifests`
      child span
      - keep route preparation visible by default while exposing manifest
      detail only with verbose tracing
      - cover normal and direct-entrypoint server lifecycles without relying
      on test ordering
      
      ## Why
      
      Route preparation is the stable boundary between loading a route module
      and executing it. The parent span shows the total setup cost; the
      aggregate manifest child explains manifest work without creating
      per-file spans or exposing paths.
      
      ## Verification
      
      - `pnpm build-all`
      - `pnpm --filter=next build`
      - `pnpm --filter=next types`
      - `pnpm exec jest packages/next/src/server/lib/trace/tracer.test.ts
      --runInBand`
      - focused OpenTelemetry E2E in development and production with Turbopack
      and Webpack
      - Request Insights route-preparation E2E with Turbopack and Webpack
      - Prettier, ESLint, and `git diff --check`
      
      ## Stack
      
      Depends on **Trace route module loading**.
      44103a87
    • David Alexandru Ilie's avatar
      Trace route module loading (#97318) · d481cfba
      David Alexandru Ilie authored
      ## Summary
      
      - trace the primary App Router and Pages Router route-module load inside
      `loadComponents`
      - expose `LoadComponents.loadRouteModule` as the default `load route
      module` OpenTelemetry span
      - verify the span in development and production with both Turbopack and
      Webpack
      
      ## Why
      
      Route-module evaluation can account for cold request time before route
      preparation and rendering begin. Keeping this boundary in the Next.js
      server makes it available to `next dev`, self-hosted `next start`,
      direct entrypoints, and deployment integrations without depending on an
      adapter-specific launcher.
      
      The span wraps only the requested route module. It does not include
      `_app`, `_document`, rendering, or any adapter launcher work, and it
      does not add filesystem paths, raw URLs, or other high-cardinality
      attributes.
      
      ## Verification
      
      - `pnpm build-all`
      - `pnpm --filter=next build`
      - `pnpm --filter=next types`
      - `pnpm exec jest packages/next/src/server/lib/trace/tracer.test.ts
      --runInBand`
      - focused OpenTelemetry E2E in `test-dev-turbo`, `test-dev-webpack`,
      `test-start-turbo`, and `test-start-webpack`
      - Prettier, ESLint, and `git diff --check`
      d481cfba
    • Steven's avatar
      962ca14d
    • Hendrik Liebau's avatar
      Scope app-entry export validation to files inside the app directory (#97350) · cdf5c37d
      Hendrik Liebau authored
      Adopts #97150. Closes #97150.
      
      Fixes #96859
      
      ### What?
      
      Since 16.3.0, builds fail for pages-router files named `sitemap` or
      `robots` that export `getStaticProps`/`getServerSideProps`:
      
      ```
      Error: "getStaticProps" is not supported in app/.
      ```
      
      This is a regression from #94962, which added the metadata conventions
      (`sitemap`, `robots`, `manifest`, `icon`, …) to the app-entry filename
      regex in `ReactServerComponentValidator::assert_invalid_api`. The regex
      only looks at the filename, so a file like `pages/sitemap.js` is now
      mistaken for an app entry and rejected for exporting `getStaticProps`.
      
      ### How?
      
      A file is only treated as an app entry when it's inside `appDir`,
      reusing the gate `assert_server_filename` already applies to `error.js`.
      The pages compilation context has no `appDir`, so pages-router files are
      never validated as app entries.
      
      On the test side:
      
      - The fixtures that exercise the app-entry checks moved under
      `app-dir/`, since the test harness derives `appDir` from the fixture
      path. Their contents are unchanged.
      - A new fixture (plus a `sitemap.js` fixture glob) asserts that a
      pages-style `sitemap.js` compiles without errors.
      - A new e2e suite, `test/e2e/pages-metadata-filenames`, covers
      `pages/sitemap.js` with `getStaticProps` and `pages/robots.js` with
      `getServerSideProps`. It fails without the fix under Turbopack (build
      and dev) and passes with it under both Turbopack and webpack.
      
      Supersedes #96873 (same approach, closed by its author) and closes
      #96967.
      
      ---------
      Co-authored-by: 's avatarRodrigo Arias <rodrigo@arias.me>
      cdf5c37d
    • Bryan Dandan's avatar
    • Hendrik Liebau's avatar
      [test] Cover `'use cache: private'` in route handlers (#97349) · 40188b5e
      Hendrik Liebau authored
      The `use-cache-private` suite covered private caches in server
      components only, so this adds a route handler that calls one `'use
      cache: private'` function three times: a concurrent pair, and a third
      call after a short delay. The concurrent pair joins a single in-flight
      invocation, while the delayed call lands after the map of pending
      intra-request invocations has dropped its entry, so it is served from
      the completed entry that the request retains. Each call passes a fresh
      object literal, which makes the React `cache()` memo miss on reference
      equality so that the lookup falls through to the serialized cache key.
      The cache function also reads a cookie, which covers that request APIs
      are allowed inside a private cache in a route handler.
      
      A second test asserts that nothing is shared across requests. In
      production private entries are neither persisted nor deduped across
      requests, so every request re-runs the cache function. In development
      they are persisted and forced to `revalidate: 0`, so the next request is
      served the stale entry while a fresh one warms in the background, which
      the dev branch of the test follows. Both tests pass their own `id`
      search param, and therefore use their own cache key, so the entry that
      dev persists for one is never served to the other.
      
      This also drops the claim that the directive is not available in route
      handlers from the `'use cache: private'` reference. Nothing in the
      source rejects it, and it was already allowed for request work unit
      stores when that note was written.
      40188b5e
    • Tim Neutkens's avatar
      Fix missing Pages runtime in adapter Pages API outputs (#96819) · d0798a04
      Tim Neutkens authored
      ## Summary
      
      ### Original issue
      
      Pages API functions produced through a build adapter can fail during
      function initialization, before the customer handler executes:
      
      ```
      Cannot find module 'next/dist/compiled/next-server/pages-turbo.runtime.prod.js'
      ```
      
      The failure is triggered when an externalized dependency used by the API
      route imports a Next.js module such as `next/head`. At runtime the load
      path is:
      
      ```
      external dependency
        -> next/head
        -> head-manager-context.shared-runtime
        -> Pages vendored head-manager context
        -> pages/module.compiled.js
        -> pages[-turbo].runtime.prod.js
      ```
      
      The two important edges at the end of this chain are selected
      dynamically. The Next.js require hook redirects the shared-runtime
      import to the Pages vendored context, and `pages/module.compiled.js`
      selects the bundler-specific production renderer. As a result, a Pages
      API entry trace does not discover the regular Pages renderer. It
      naturally contains `pages-api[-turbo].runtime.prod.js`, which is the
      runtime for the API route module, but not
      `pages[-turbo].runtime.prod.js`, which is reached through the external
      `next/head` import.
      
      This is why the failure is specific to Pages API routes. A regular Pages
      SSR entry already references and traces the Pages renderer. App Router
      entries use different route modules and traces.
      
      ### Fix
      
      Trace the hidden Pages renderer dependency using the mechanism
      appropriate to each bundler:
      
      - **Turbopack:** add `pages-turbo.runtime.prod.js` as an explicit entry
      in `Project::pages_traced_modules`. The existing native Turbopack module
      graph then traces its full runtime closure. This does not run Node File
      Trace and remains scoped to Pages endpoints.
      - **Webpack:** run the existing Node File Trace path on
      `pages.runtime.prod.js` and merge that closure into the Pages shared
      assets. This code remains inside the non-Turbopack branch.
      
      The existing require-hook modules remain separate, and App Router or
      neutral endpoint trace sets are unchanged. No adapter change is
      required.
      
      ### Regression test
      
      The fixture externalizes a package that imports `next/head`, matching
      the reported dependency boundary. The test builds with an adapter,
      materializes only the generated Pages API function entry and its
      provided assets into a clean directory, initializes the production
      environment, and requires the handler in a child process.
      
      This verifies the observable initialization behavior under both
      Turbopack and Webpack rather than asserting a particular output file
      list.
      
      ## Verification
      
      - `cargo check -p next-api`
      - `pnpm --filter=next build`
      - `pnpm test-start-turbo
      test/production/adapter-pages-api-runtime/adapter-pages-api-runtime.test.ts`
      - `pnpm test-start-webpack
      test/production/adapter-pages-api-runtime/adapter-pages-api-runtime.test.ts`
      
      <!-- NEXT_JS_LLM -->
      Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
      d0798a04
    • Aurora Scharff's avatar
    • Gary Tyr's avatar
      Update blob version. (#97342) · a4420747
      Gary Tyr authored
      a4420747