1. 09 Sep, 2026 38 commits
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.25 · 334052ff
      next-js-bot[bot] authored
      334052ff
    • Josh Story's avatar
      test: restore deployment exclusion for shared Cache Components tests (#98464) · 1f60b5f1
      Josh Story authored
      ## Summary
      
      Restore `skipDeployment` and the early return in the shared Cache
      Components error-test runner. The migration in #98154 replaced them with
      a force-gate pragma, but the gate transformer only processes `.test.*`
      files, so the pragma in `shared.util.ts` did not preserve the deployment
      exclusion.
      
      This is a temporary rollback to unblock deploy testing. Moving the test
      definitions out of the helper and migrating them again will be evaluated
      separately; this PR does not change the transformer or refactor the
      tests.
      
      ## Verification
      
      - Ran all 12 importing test files through Jest in deploy mode with
      deployment setup mocked to throw before any fixture or deployment work.
      Before the rollback, all 12 reached that guard and failed. After the
      rollback, all 12 take the legacy exclusion path and no deployment setup
      is attempted.
      - `pnpm typescript --skipLibCheck` passes.
      - Full type-check reports the existing nine Octokit dependency
      declaration errors; no errors in the changed file.
      
      <!-- NEXT_JS_LLM -->
      1f60b5f1
    • Josh Story's avatar
      Resolve metadata independently across parallel routes (#97345) · cd7fa800
      Josh Story authored
      ## Motivation
      
      Parallel routes are separate rendering branches, but the existing
      metadata resolver collects every matched slot into one shared chain. As
      a result, traversal order can decide which slot supplies the document
      head, and metadata errors from one slot can interfere with another.
      
      ## What this does
      
      This adds a fork-aware resolver behind
      `experimental.parallelRouteMetadata` while retaining the existing
      resolver as the default. Each slot resolves metadata and viewport
      independently, with isolated accumulators, and a single branch is
      selected for the document head at every fork.
      
      The built-in selector prefers real routes over implicit fallbacks and
      prefers `children` when it contributes head data. Otherwise it chooses
      the branch with the deepest head definition, using route depth and
      lexical slot order only as stable tie-breakers.
      
      Head selection is separate from rendering outcomes. Every slot gets its
      own `MetadataOutlet`, which replays navigation and regular errors for
      that slot regardless of which branch supplied the head.
      
      ## Review notes
      
      - `generateMetadata`, `generateViewport`, and generated static metadata
      still start eagerly; a fork does not serialize sibling branches or
      parent/child generation.
      - Branch state is isolated only where the tree forks, preventing
      metadata mutation from crossing between slots.
      - An outlet rejects as soon as either metadata or viewport rejects, but
      resolves only after both succeed. This lets one failing result reach the
      slot boundary even if the other never settles.
      - Existing navigation convention metadata is preserved for the selected
      branch. Errors from unselected branches remain observable only through
      their own rendered outlets.
      - The old resolver remains available behind an explicit flag so this
      implementation can be compared or disabled during rollout.
      
      ## Verification
      
      - `pnpm --filter=next types`
      - Metadata resolver unit coverage
      - Parallel-route metadata, navigation, and not-found coverage in
      development and production with Turbopack and webpack
      
      <!-- NEXT_JS_LLM -->
      cd7fa800
    • Aurora Scharff's avatar
      docs: preserve route behavior during Cache Components adoption (#98275) · 2aaa6e81
      Aurora Scharff authored
      ## Summary
      
      - Explain that removing `dynamic = 'force-dynamic'` moves a route from
      full request-time rendering to Cache Components' Partial Prerendering
      model, then document the choices for its request-time work.
      - Preserve routes that previously used `dynamic = 'force-static'` or
      `dynamic = 'error'` instead of leaving them under `instant = false`,
      which can move rendering to request time and reduce prefetched UI.
      - Clarify that existing `fetch` and `unstable_cache` caching can remain
      in place during adoption.
      - Combine the incremental checkpoint and completion coverage into one
      eval that verifies both stages of the migration.
      - Make the adoption skill honor an explicit incremental strategy before
      continuing through a complete migration.
      - Remove the unrelated `.env*` ignore and restore the existing agent-054
      eval registration.
      
      ## Eval results
      
      `agent-047-adopt-cache-components` runs the complete incremental
      migration with `openai/gpt-5.6-luna` through the Codex harness. It
      retains the original five checks for the first shippable checkpoint and
      the original seven checks for completing the migration.
      
      | Treatment | Result | Notes |
      | --- | --- | --- |
      | Baseline | 11/12 | Preserved the final behavior, but treated the work
      as a fresh migration instead of explicitly continuing from the recorded
      first checkpoint. |
      | Guide (`AGENTS.md`) | 8/12 | Built successfully, but rewrote the
      existing `unstable_cache`, changed the catalog's hourly cadence, moved
      its timestamp to request time, and skipped the recorded incremental
      checkpoint. |
      | Adoption skill | 12/12 | Preserved both cache lifetimes and static
      contracts, recorded a passing incremental checkpoint, removed the
      remaining opt-outs, and completed the migration. |
      
      ## Verification
      
      - `pnpm build`
      - Luna eval runs for the baseline, guide, and adoption-skill treatments
      - Prettier and ESLint checks for the changed guide, skill, and eval
      files
      - `git diff --check`
      
      <!-- NEXT_JS_LLM -->
      2aaa6e81
    • Benjamin Woodruff ‮'s avatar
      Add a fast-path to 'get_relative_path_to' for a potential common case when 'from' is empty (#98440) · be2c3fdb
      Benjamin Woodruff authored
      When creating an NFT file in
      https://github.com/vercel/next.js/pull/98003, I store a generic list of
      "base" paths and then construct the final path in the JSON file as
      relative to the base path. For most files, these paths are relative to
      the `*.nft.json` file, but for additional roots, this base path is
      always an empty string (relative to the root of the filesystem), so
      being able to re-use the original `RcStr` instead of constructing a
      brand new string may be beneficial.
      
      This also moves the unit tests to be colocated next to the functions
      that are actually being tested.
      be2c3fdb
    • Aurora Scharff's avatar
      docs: document React browser API (#97621) · 526c492a
      Aurora Scharff authored
      ### What?
      
      - Documents React Canary's new `browser` API in the SPA guide
      - Adds examples for marking a Client Component as browser-only and
      wrapping it in Suspense
      
      ### Why?
      
      The App Router includes React Canary releases, and the `browser` API now
      provides a Suspense-based option for components that depend on browser
      APIs such as `window` or `document`.
      
      ### How?
      
      The guide calls `browser()` inside `use()` in a Client Component. It
      then wraps that component in Suspense so prerendering can show the
      closest fallback before the component renders in the browser.
      
      ### Testing
      
      - `prettier --check docs/01-app/02-guides/single-page-applications.mdx`
      - `alex docs/01-app/02-guides/single-page-applications.mdx --quiet`
      (only existing SPA dictionary warnings)
      526c492a
    • Jiwon Choi's avatar
      Enable React browser bailout by default (#98439) · 67f42155
      Jiwon Choi authored
      Enable React browser bailouts by default without requiring applications
      to opt in.
      67f42155
    • Will Binns-Smith's avatar
      bundle-analyzer: record historical snapshots on each analyze run (#93520) · 57a84760
      Will Binns-Smith authored
      After each `next experimental-analyze` run, snapshot the output data
      into a rolling `history/` directory so later builds can use it as a
      comparison baseline.
      
      Each snapshot gets a `metadata.json` with git branch/sha/dirty status,
      Next.js version, and route count. A `history/history.json` index
      (newest-first, capped at 20 entries) lets the UI list available
      baselines without re-reading every snapshot directory. Old snapshots
      beyond the cap are pruned automatically.
      
      The client-side `SnapshotMetadata` type mirror lives in
      `apps/bundle-analyzer/lib/snapshot.ts` so the compare UI can reference
      it without a build-time dependency on the Next.js package.
      
      <!-- NEXT_JS_LLM_PR -->
      
      ---------
      Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarWill Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
      57a84760
    • Aurora Scharff's avatar
      [evals] Cover focused Cache Components and Partial Prefetching cases (#97813) · 9486750f
      Aurora Scharff authored
      ## Summary
      
      - update existing evals for synchronous I/O, instant shell validation,
      and Cache Components configuration instead of adding duplicate fixtures
      - add focused Partial Prefetching coverage for URL-data inclusion, the
      prefetch stage, and the navigation stage
      - retain focused Cache Components coverage for session isolation and
      URL-dependent shells
      - rebase onto current `canary` so the Partial Prefetching evals can use
      the public `unstable_prefetch()` and `unstable_navigation()` API
      references
      
      ## Coverage
      
      The latest results use Claude Sonnet 4.6 for the coding agent and Claude
      Haiku 4.5 for the agentic judge. The Partial Prefetching cases have been
      rerun after the new API references landed, and the corrected Cache
      Components criteria have also been rerun.
      
      | Eval | Scenario | Baseline | Bundled docs |
      | --- | --- | ---: | ---: |
      | `agent-035-connection-dynamic` | Adopt Cache Components while keeping
      synchronous request-time values fresh and stable navigation in the shell
      | 5/5 | 5/5 |
      | `agent-040-instant` | Follow default validation and keep a stable
      product title ahead of live inventory | 4/4 | 4/4 |
      | `agent-042-enable-ppr` | Translate legacy route configuration while
      preserving hourly and request-specific behavior | 4/4 | 4/4 |
      | `agent-048-prefetch-url-data` | Include cached URL-specific category
      content in a selected per-link prefetch | 3/6 | 6/6 |
      | `agent-049-prefetch-stage` | Exclude cached content from the App Shell
      but include it in a selected prefetch | 1/5 | 5/5 |
      | `agent-051-prefetch-until-navigation` | Prefetch a selected title
      while deferring the rest until navigation | 0/5 | 5/5 |
      | `agent-052-cache-components-session-isolation` | Reuse shared data
      without placing member-specific request data in a public cache | 5/5 |
      5/5 |
      | `agent-053-cache-components-url-shell` | Keep URL data below a useful
      shell and include every output-changing value in the cache key | 3/5 |
      5/5 |
      
      After the public API references landed, the prefetch-stage and
      navigation-stage evals show the intended documentation signal. Baseline
      Sonnet passed 1/5 criteria for `unstable_prefetch()` and 0/5 for
      `unstable_navigation()`. With the canonical bundled-docs instruction,
      Sonnet found the new references and passed all 5/5 criteria in both
      cases. After clarifying that the URL-data navigation must not block and
      linking the general navigation docs to the optimizing-prefetching guide,
      the URL-data case improved from 3/6 without docs to 6/6 with bundled
      docs.
      
      ## Result interpretation
      
      - `agent-048` now passes 6/6 with bundled docs. The scoped documentation
      link led the agent to the URL-data prefetch pattern instead of a
      blocking render. Baseline Sonnet added `prefetch={true}` but relied on
      the previous full-payload behavior and missed both the Partial
      Prefetching configuration and cached URL data, resulting in 3/6.
      - The low baseline scores for `agent-049` and `agent-051` are the
      intended signal. Without the new references, the agents did not discover
      the prefetch and navigation stages. With bundled docs, both cases pass
      5/5.
      - `agent-053` is also an intended documentation signal: the baseline hid
      the useful shell behind a broad fallback, while bundled docs preserved
      the shell and passed 5/5.
      - `agent-035` now passes 5/5 in both conditions after removing an
      unnecessary requirement for visible loading UI in one small metadata
      region. `agent-052` also passes 5/5 in both conditions after removing
      two failures for an omitted explicit `cacheLife()`, because the default
      cache profile still applies, and clarifying for the judge that an
      uncached component reading `cookies()` or `headers()` remains
      request-specific without another opt-out marker.
      
      ## Overlap decisions
      
      - `agent-035` now carries the synchronous-I/O adoption case, so the
      duplicate `agent-051` fixture was removed.
      - `agent-042` now carries the route-configuration migration case, so the
      duplicate `agent-048` fixture was removed.
      - `agent-034` remains focused on correct async `cookies()` and
      `headers()` usage. `agent-052` tests the separate risk of leaking
      request-specific values through a public cache.
      - `agent-040` tests one meaningful shell under default validation.
      `agent-041` still tests independent streaming across several dashboard
      sections.
      - `agent-048` intentionally brings cached URL-specific content into a
      selected prefetch. `agent-053` tests the opposite shared-shell
      requirement during Cache Components adoption.
      
      ## Verification
      
      - Dry fixture generation passes for all eight cases in the table.
      - `pnpm build-all`
      - `agent-049-prefetch-stage`: baseline 1/5, bundled docs 5/5
      - `agent-051-prefetch-until-navigation`: baseline 0/5, bundled docs 5/5
      - `agent-035-connection-dynamic`: baseline 5/5, bundled docs 5/5
      - `agent-048-prefetch-url-data`: baseline 3/6, bundled docs 6/6
      - `agent-052-cache-components-session-isolation`: baseline 5/5, bundled
      docs 5/5
      - `pnpm exec tsc -p
      evals/evals/agent-035-connection-dynamic/tsconfig.json --noEmit`
      - `pnpm exec tsc -p evals/evals/agent-042-enable-ppr/tsconfig.json
      --noEmit`
      
      <!-- NEXT_JS_LLM -->
      9486750f
    • Luke Sandberg's avatar
      a8905ddf
    • Jimmy Miller's avatar
      Adds this.target for webpack loaders (#98436) · b8797762
      Jimmy Miller authored
      There are a bunch of different loaders I found depending on this
      
      - vue-loader
      - svelte-loader
      - svg-sprite-loader
      - nunjucks-loader
      - workerize-loader
      - worklet-loader
      - nativescript-worker-loader
      - thread-loader
      - svg-sprite-generation-loader
      
      This doesn't by itself fix any of them fully, but does increase
      compatibility
      b8797762
    • Jude Gao's avatar
      test(evals): validate delegated error boundary components (#98387) · 4d621240
      Jude Gao authored
      Fixes false failures in `agent-030-app-router-migration-hard` when
      `app/error.tsx` delegates to a shared component through an import,
      re-export, or wrapper. Replaces the source-text regex with a semantic
      check that follows the exported implementation and validates recovery
      against the installed Next.js API, accepting supported `retry` or
      `reset` callbacks.
      
      Validated with the corrected Astra runs and nine additional experiment
      reruns in https://github.com/vercel/next-evals-oss/pull/120. All nine
      passed under pass@4; published scores are unchanged. Four Grok
      experiments were blocked by provider access restrictions.
      4d621240
    • Tobias Koppers's avatar
      test: stabilize deferred entries HMR assertions (#98418) · 9c8b238a
      Tobias Koppers authored
      ### What?
      
      Stabilize the deferred-entries development-mode HMR assertions by giving
      condition-based callback, rendered-output, and page-content polling an
      HMR-appropriate retry budget.
      
      ### Why?
      
      Canary CI repeatedly observed the previous callback timestamp after a
      non-deferred edit. The logs show webpack detecting and compiling the
      edit, while its multi-compiler HMR cycle—including the edge
      compiler—finishes after the generic three-second retry window. The
      deferred callback is scheduled after that cycle, so these failures
      reflect the harness timing out before valid product behavior rather than
      a deferred-entries product defect.
      
      ### How?
      
      Use a shared ten-second retry duration only for the six HMR-observable
      polls in the existing dev-only tests. The checks still wait on real
      callback timestamps, rendered values, and updated page content. Existing
      ordering and callback-stability assertions remain unchanged, so missing
      callbacks, stale rendering, and callback loops continue to fail.
      
      ### Verification
      
      - `pnpm test-dev-webpack
      test/e2e/deferred-entries/deferred-entries.test.ts` (3 consecutive runs,
      23/23 each, with CI environment mirrored)
      - `pnpm test-dev-turbo
      test/e2e/deferred-entries/deferred-entries.test.ts` (23/23)
      - `pnpm prettier --with-node-modules --ignore-path .prettierignore
      --write test/e2e/deferred-entries/deferred-entries.test.ts`
      - `npx eslint --config eslint.config.mjs --fix
      test/e2e/deferred-entries/deferred-entries.test.ts`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 3cae6bf2-a515-4375-8814-03055b906f2a -->
      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>
      9c8b238a
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.24 · dea82ba4
      next-js-bot[bot] authored
      dea82ba4
    • Will Binns-Smith's avatar
      Re-enable @vercel/devlow-bench publishing (#98236) · de356c6d
      Will Binns-Smith authored
      
      Revert 699ee92b to publish
      `@vercel/devlow-bench` again. Trusted publishing has now been set up, so
      the package should publish correctly.
      Co-authored-by: 's avatarSebastian "Sebbie" Silbermann <sebastian.silbermann@vercel.com>
      de356c6d
    • Josh Story's avatar
      test: migrate caching deploy exclusions to force gates (#98154) · e0966df1
      Josh Story authored
      ## Summary
      
      - migrate Cache Components, PPR, prefetching, prerendering,
      revalidation, and SSG deployment exclusions to `@force-gate`
      - remove the corresponding `skipDeployment` options and `skipped`
      control flow while preserving each suite's rationale
      
      This keeps caching-related exclusions together so their deployed
      semantics can be reviewed by the same owners.
      
      ## Verification
      
      - verified on the combined top-of-stack tree with `pnpm typescript`
      - compared ordinary-mode collection before and after: all 4,670 existing
      test names matched
      - collected all 510 affected files in deploy mode: 4,578 skipped tests,
      zero failures
      
      <!-- NEXT_JS_LLM -->
      e0966df1
    • Tobias Koppers's avatar
      Typecheck the Turbopack ECMAScript runtime in CI (#98422) · 6caa7860
      Tobias Koppers authored
      ### What?
      
      Integrate the Turbopack ECMAScript runtime package checks into the
      repository TypeScript task graph and resolve the latent type errors
      those checks expose.
      
      ### Why?
      
      The runtime package already had checks for its environment-specific
      TypeScript projects, but CI never executed them. This allowed its public
      runtime context types to diverge from their implementations, including
      the `EsmExport` binding representation.
      
      ### How?
      
      The package now participates in the existing Turbo `typescript` task
      used by CI. Its package-local Turbo configuration builds workspace
      dependencies first, ensuring the React Refresh type output is available
      on clean checkouts without adding build dependencies to every repository
      typecheck.
      
      The runtime declarations now reflect the actual flat ESM binding format
      and HMR behavior. Browser development references and return types also
      mirror the runtime files and concatenation order used by the Rust
      runtime builder. Turbopack snapshots that embed these runtime sources
      and source maps are regenerated to match.
      
      ### Verification
      
      - `cargo nextest run -p turbopack-tests -E 'test(snapshot)'` (125
      passed)
      - `pnpm --dir turbopack/crates/turbopack-ecmascript-runtime/js check`
      - `pnpm lint-typescript --filter=@vercel/turbopack-ecmascript-runtime
      --log-order=stream --force` after removing
      `packages/react-refresh-utils/dist`
      - Focused Prettier and ESLint checks
      - `git diff --check`
      
      <!-- NEXT_JS_LLM -->
      
      <!-- fleet 56074f5a-b0e2-4b27-ac56-a2b6cebe3c8e -->
      
      ---------
      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>
      6caa7860
    • Tobias Koppers's avatar
      Fix initial Turbopack HMR update handling (#98385) · b145ad6f
      Tobias Koppers authored
      ### What?
      
      Prevent a real client HMR update from being discarded when it arrives as
      the first subscription emission.
      
      ### Why?
      
      Capturing the chunk baseline and installing the update subscription are
      separate asynchronous operations. A change between them turns the first
      emission into a real update, but the client handler previously assumed
      that emission was always initialization-only and dropped it after the
      server had advanced its version state.
      
      ### How?
      
      Inspect the first subscription result and preserve the existing
      issues-only initialization behavior while forwarding partial or restart
      updates through the normal issue and browser-update paths. This is the
      narrower option because it does not change handling of the usual initial
      issues payload.
      
      ### Verification
      
      - `pnpm --filter=next build`
      - `HEADLESS=true pnpm test-dev-turbo
      test/development/app-dir/hmr-dynamic-component/hmr-dynamic-component.test.ts`
      (including a locally controlled baseline-to-subscription race)
      - Prettier and ESLint on the changed source
      
      <!-- NEXT_JS_LLM -->
      
      <!-- fleet 3820fb8a-c662-4c74-8316-e2d7cd42bfbd -->
      
      ---------
      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>
      b145ad6f
    • Will Binns-Smith's avatar
      Skip bundler config validation in next/jest and under test (#98392) · fc977d6d
      Will Binns-Smith authored
      ## Summary
      
      Skip active-bundler config validation when `next/jest` loads
      `next.config.*` under `PHASE_TEST`. Jest uses the Next.js SWC
      transformer without running Turbopack or webpack, so bundler-specific
      options should remain available without requiring phase-dependent user
      config.
      
      Add regression coverage for `experimental.turbopackRustReactCompiler`
      and `experimental.cssChunking: 'graph'` in the test phase.
      
      ## Verification
      
      - `pnpm test-unit test/unit/isolated/config.test.ts -t "Should allow
      bundler-specific options during the test phase"`
      
      <!-- NEXT_JS_LLM -->
      fc977d6d
    • Sebastian "Sebbie" Silbermann's avatar
      Remove `tsec` (#98423) · 9db9b8ef
      Sebastian "Sebbie" Silbermann authored
      tsec enforces nothing today. Of its 22 rules, 16 have no callsite in the
      four packages it checks, 5 find violations that are all suppressed by
      tsec-exemptions.json, and ban-element-innerhtml-assignments has been
      inert since TypeScript dropped the `InnerHTML` mixin from lib.dom.d.ts,
      so its matcher resolves to no type. Net enforced findings: zero.
      
      font, third-parties and next-playwright never extended
      tsconfig-tsec.json, so they ran all 22 rules over source with no DOM
      sinks at all, paying a full extra type-check each for nothing.
      9db9b8ef
    • Tobias Koppers's avatar
      Stabilize scope_unbounded panic test (#98416) · f17979b0
      Tobias Koppers authored
      ### What?
      
      Make `test_unbounded_panic_propagates_and_abandons_queue`
      deterministically exercise panic-driven queue abandonment.
      
      ### Why?
      
      The test failed in two consecutive canary `test-cargo-unit` attempts
      after all 10,000 fixed seed items ran before the panic's abort was
      recorded. That outcome is legal scheduling: a fixed seed queue can drain
      before its designated panicking item executes, so the assertion did not
      prove that abort handling was broken.
      
      ### How?
      
      The test now grows a bounded work cascade and panics after a fixed
      amount of processing. Since each completed item adds more work, queued
      items are guaranteed to exist when the panic occurs. The test therefore
      continues to verify panic propagation and queue abandonment without
      relying on worker timing. Production `scope_unbounded` behavior is
      unchanged.
      
      ### Verification
      
      - Changed panic test passed 100 consecutive runs with
      `release-with-assertions`
      - `cargo nextest run -p turbo-tasks -E 'test(~scope_unbounded::tests::)'
      --cargo-profile release-with-assertions` (17 passed)
      - `cargo fmt --all -- --check`
      - `git diff --check`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet ae1d9ec9-156e-4b53-80c0-f24bf0b22f13 -->
      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>
      f17979b0
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.23 · 42779fe7
      next-js-bot[bot] authored
      42779fe7
    • Niklas Mischkulnig's avatar
      Turbopack: fix require handling with alternative (#98258) · f367ab34
      Niklas Mischkulnig authored
      Regression from 
      - https://github.com/vercel/next.js/pull/97867 (which uncovered this bug
      in this particular case with the default parameter assignment)
      and
      - https://github.com/vercel/next.js/pull/97697 (because previously
      `unknown | WellKnownFunction` was just unknown. Now it stays `unknown |
      WellKnownFunction`)
      
      Fixes
      ```
      ./node_modules/.pnpm/@vue+compiler-sfc@3.5.26/node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js:45756:20
      Error: Module not found: Can't resolve 'less'
        45754 | );
        45755 | const less = (source, map, options, load = require) => {
      > 45756 |   const nodeLess = load("less");
              |                    ^^^^^^^^^^^^
      ```
      
      because basically
      ```js
      const load = globalThis.foobar || require
      const x = load("less");
      ```
      would get replaced to
      ```js
      const load = globalThis.foobar || require
      const x = __turbopack_context__.require(191912); 
      ```
      which would be wrong if `globalThis.foobar` isn't actually `require` at
      runtime.
      
      Instead, if we are inside an alternative, don't emit a codegen
      replacement but only add reference
      f367ab34
    • Aurora Scharff's avatar
      docs: clarify ISR with Suspense params (#98210) · f8657de1
      Aurora Scharff authored
      ## Summary
      
      - warn that awaiting params inside Suspense without Partial Prefetching
      prevents unlisted paths from using ISR
      - clarify that route data may still be cached even though the
      URL-specific route renders on each request
      - link the migration warning to the ISR with Cache Components guide
      
      ## Why
      
      This follows up on #98209. The migration eval showed that an agent can
      preserve generateStaticParams but move params beneath Suspense while
      Partial Prefetching is disabled. That produces a fallback shell, but
      unlisted paths do not use ISR.
      
      Context:
      https://github.com/vercel/next.js/discussions/98177#discussioncomment-18252316
      
      ## Testing
      
      - git diff --check
      - Prettier check for both changed guides
      - commit hooks: Prettier and ESLint
      f8657de1
    • Sebastian "Sebbie" Silbermann's avatar
      [cd] Update `peerDependencies` in prereleases to accept the current prerelease (#98411) · 59b76e42
      Sebastian "Sebbie" Silbermann authored
      https://github.com/vercel/next.js/pull/98330 revealed theat
      `@next/third-parties` never worked with prereleases after 16.0. Now we
      [update `peerDependencies` similar to what we do for preview builds
      already](https://github.com/vercel/next.js/blob/27f679224e2660971377f855ced51093462734d8/scripts/create-preview-tarballs.js#L130-L132)
      (we should unify both eventually to go through the same flow).
      
      Fixes
      ```
        npm error code ERESOLVE
        npm error ERESOLVE unable to resolve dependency tree
        npm error
        npm error While resolving: undefined@undefined
        npm error Found: next@16.4.0-canary.22
        npm error node_modules/next
        npm error   next@"16.4.0-canary.22" from the root project
        npm error
        npm error Could not resolve dependency:
        npm error peer next@"^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0-beta.0" from @next/third-parties@16.4.0-canary.22
        npm error node_modules/@next/third-parties
        npm error   @next/third-parties@"16.4.0-canary.22" from the root project
      ```
      -- https://github.com/vercel/next.js/actions/runs/34291905918/attempts/2
      59b76e42
    • Tobias Koppers's avatar
      test: stabilize error recovery snapshot timing (#98414) · 56b95f41
      Tobias Koppers authored
      ### What?
      
      Stabilizes the pages-router `syntax > runtime error` acceptance test
      without weakening its redbox assertions.
      
      ### Why?
      
      The fixture emitted runtime errors every second and waited exactly one
      second before capturing the first redbox. On slower release runners, a
      second error could arrive while the asynchronous snapshot was being
      collected, changing the expected single error into an array and causing
      repeated retries.
      
      The broader canary assertion cluster has several independent signatures;
      this PR intentionally addresses only the timing race with a
      reproducible, test-local cause.
      
      ### How?
      
      The redbox matcher now performs the initial wait itself, while the
      fixture uses a longer interval to leave a stable capture window. The
      later wait remains long enough for another runtime error to occur,
      preserving the test’s core assertion that a subsequent runtime error
      does not replace the syntax/build error.
      
      ### Verification
      
      - `pnpm build-all`
      - `HEADLESS=true NEXT_TELEMETRY_DISABLED=1 NEXT_TEST_CI=true pnpm
      test-dev-webpack test/development/acceptance/error-recovery.test.ts` (6
      tests and 10 snapshots passed)
      - Prettier and ESLint on the changed file
      
      <!-- NEXT_JS_LLM -->
      
      <!-- fleet ee9dd3ec-a271-4d0d-8165-d7872e226a6a -->
      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>
      56b95f41
    • Joseph's avatar
      example: Use a Redis cacheHandler w/o dependencies (#95346) · 26b2bbe0
      Joseph authored
      Verify locally:
      
      - Copy the example to a local directory
      - Install deps
      - docker compose up -d
      - npm run build && npm run start 
      - navigate to localhost:3000/cet (or gmt)
      - open the Redis view (link in localhost:3000/cet)
      - revalidate data on /cet or /gmt
      - verify it on the Redis view
      
      I had to update the app to async params, updateTag, and write the
      handler in such a way that it solved:
      
      ```
      ⨯ TypeError: p.segmentData.get is not a function
          at ignore-listed frames
      ⨯ Error: failed to pipe response
      ```
      
      Also adding docs edits with this caveat.
      
      An agent review, and cross checking with a community implementation,
      surfaced, that we had to read tags from
      `data.headers['x-next-cache-tags']`. This agent review added a few
      comments, I think they are useful, but can cut down if needed.
      
      Last but not least, had to update the Time API endpoint (former no
      longer worked).
      26b2bbe0
    • Niklas Mischkulnig's avatar
      Support durable use-cache entries with client components (#98140) · 3c8e9c38
      Niklas Mischkulnig authored
      The current setup is:
      1. A use-cache function returns an RSC value that may contain client
      reference proxies. Flight serializes each reference using the client
      module `id`, export `name`, client `chunk` list, and `async`. The
      resulting Flight payload is stored in the cache entry.
      2. When decoding the cache entry, the client module `id` is resolved
      through `rscModuleMapping` to obtain the corresponding RSC module `id`
      and `export`.
      
      Cache decoding does not need the client chunk list because it does not
      load client chunks. The outer RSC serialization emits the client
      reference again using the current client reference manifest, including
      the current chunks. We can therefore serialize cached references with an
      empty chunk list.
      
      The client module `id` is also unstable across builds. Instead, cache
      entries can store the stable client reference name. When decoding, we
      resolve: client reference name -> current client module ID -> current
      RSC module ID
      This makes cached client references independent of build-specific module
      IDs and chunk filenames.
      3c8e9c38
    • next-js-bot[bot]'s avatar
    • Anuj Bolewar's avatar
      fix: preserve repeated --require/--import flags when forking workers (#96651) · aad56b54
      Anuj Bolewar authored
      Repeated --require/--import flags in NODE_OPTIONS are corrupted when
      Next.js reparses and reformats the options for forked workers.
      
      ## What changed
      
      - Declare `require` and `import` as repeatable options in
      `parseNodeArgs` so `parseArgs` accumulates every occurrence into an
      array instead of keeping only the last value (equals form) or joining
      the space form into one bogus specifier.
      - Emit one flag per array element in `formatArg`/round-trip.
      - Widened `NodeOptions` and `getParsedDebugAddress` to accept
      `string[]`.
      
      ## Why
      
      Two preloads in `NODE_OPTIONS` (e.g. an APM agent plus an env loader)
      silently lose one in forked workers (`--require=a --require=b`), or
      crash the build (`--require a --require b`, joining paths into a single
      MODULE_NOT_FOUND). Node itself runs every occurrence; the round-trip
      through Next must preserve them.
      
      Fixes #96582
      
      ## Validation
      
      - Unit tests in `packages/next/src/server/lib/utils.test.ts` cover both
      spellings, repeated `--import`, quoted values, and array formatting (22
      passing).
      - `pnpm --filter=next types` clean.
      Signed-off-by: 's avatarAnuj Bolewar <bolewara@gmail.com>
      aad56b54
    • Tobias Koppers's avatar
      ci: check that Turbopack compiles for wasm (#97588) · e44c5f19
      Tobias Koppers authored
      ### What?
      
      Adds a CI job that checks Turbopack compiles for
      `wasm32-wasip1-threads`, so wasm portability
      regressions are caught rather than rediscovered.
      
      ### Why?
      
      Everything under `#[cfg(target_family = "wasm")]` is invisible to host
      builds **and** to host clippy —
      it is only checked when you deliberately build for the target. Four
      separate defects in this stack were
      caught only that way (a wrong build-script condition, two bad imports,
      and a value that compiled but was
      wrong). Without a gate, the next one lands unnoticed.
      
      This also re-enables coverage that had been off for ~2 years: the old
      `test-next-napi-bindings-wasi` job
      was disabled with `if: false` pending napi-rs/napi-rs#2009, which closed
      in April 2024.
      
      ### How?
      
      Modelled on `rust-check` via `build_reusable.yml` (`needsRust`,
      `skipInstallBuild`, `skipNativeBuild`),
      so it does not pay for a JS build. Beyond `rustup target add` it needs
      two things:
      
      - **a WASI C toolchain**, because `lzzzz` (LZ4, via `turbo-persistence`)
      and `zstd-sys` have C build
      scripts. The SDK build is selected from `$RUNNER_ARCH` —
      `build_reusable.yml` defaults to an arm64
      runner, and an x86_64 clang fails there with `Exec format error` — with
      a pinned sha256 per arch,
        unpacked under `$RUNNER_TEMP` so the workspace stays clean.
      - **emnapi**, because `next-napi-bindings`' build script calls
      `napi_build::setup()`, whose wasi path
      panics without `EMNAPI_LINK_DIR` — so it is required even for `cargo
      check`. It is installed into a
      scratch directory rather than the root `package.json`, because this job
      runs with `skipInstallBuild`
        and therefore never runs `pnpm install`.
      
      Two things worth recording, both of which cost a CI round trip to find:
      
      - pnpm is invoked from the repo root with `--dir`, not by `cd`-ing into
      the scratch directory: corepack
      resolves the pnpm version from the nearest `package.json`, and outside
      the repo it picks the latest
        pnpm (11.x), which cannot run on the pinned Node 20
        (`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`).
      - the job is added to `tests-pass`, whose `needs:` list is what actually
      blocks a PR — a job that runs
      but is absent from that list looks like coverage while blocking nothing.
      
      The `emnapi@2.0.0-alpha.4` pin is deliberate and is the one fragility
      here: the archive must define
      `emnapi_create_env` / `emnapi_delete_env`, which exists only in emnapi
      v2, still a prerelease. Move to
      the stable release once it ships.
      
      
      <!-- fleet b6d0486f-97c7-42a7-bdaf-3490774cdec3 -->
      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>
      e44c5f19
    • Tobias Koppers's avatar
      feat(next-napi-bindings): build Turbopack for wasm (#97586) · 73a26bfc
      Tobias Koppers authored
      ### What?
      
      Builds Turbopack for wasm, so the wasm fallback can support Turbopack
      and not just SWC.
      
      ### Why?
      
      `next-napi-bindings` gated every Turbopack dependency behind
      `cfg(not(target_arch = "wasm32"))`, so the
      wasm fallback shipped SWC only. That is the reason issues like #96960
      have no answer today: when the
      native binding cannot load there is no Turbopack at all.
      
      ### How?
      
      Moves the Turbopack dependencies into the shared dependency block,
      leaving genuinely native-only crates
      gated:
      
      - `lightningcss` / `turbopack-lightningcss-napi` and
      `swc_ecma_react_compiler` back the `css` and
        `react_compiler` modules;
      - `swc_plugin_backend_wasmtime` cannot run inside wasm;
      - SWC's plugin-host features, gated in the previous layer;
      - `tokio`'s `full` feature pulls in `process` and `signal`, which do not
      exist on wasi, so the wasi build
        gets its own `tokio`.
      
      This is the layer at which `swc` first gets compiled for wasm, which is
      why the plugin-host gating has
      to land **before** it: with that in place, `cargo check -p
      next-napi-bindings --target
      wasm32-wasip1-threads` passes here with no `[patch.crates-io]` override.
      
      ### What this does *not* do
      
      It makes Turbopack **compile** for wasm. It does not make it run: still
      outstanding are the
      `env.read_custom_section` loader hook, a wasm `module_init` for the
      tokio runtime and panic hook, a
      host-provided fetch, the persistent cache (WASI preview1 has no
      file-backed mmap or flock), and file
      watching. Shipping is separately blocked on the unreleased emnapi v2.
      
      `turbo-tasks-malloc`'s `custom_allocator` feature also stays off, so
      there is no per-thread allocation
      accounting on wasm and memory figures are absent from traces — an
      observability gap, not a correctness
      one.
      
      
      <!-- fleet b6d0486f-97c7-42a7-bdaf-3490774cdec3 -->
      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>
      73a26bfc
    • Niklas Mischkulnig's avatar
      Add CSP nonce to script tags of loading and template files (#98398) · 8b037a67
      Niklas Mischkulnig authored
      Recreation of https://github.com/vercel/next.js/pull/98152 so that
      deployment test credentials are available in CI
      Closes #98152
      Closes https://github.com/vercel/next.js/pull/92803
      Original description:
      
      > `createComponentStylesAndScripts` renders the script tags for a
      segment's loading, error, and templatefound files, but unlike
      getLayerAssets it did not pass `ctx.nonce`. When such a file has a chunk
      that no layout or client reference has already loaded, the tag is served
      without a nonce and a nonce-based Content-Security-Policy blocks it.
      
      ### What?
      
      Patches a bug we encountered while using
      [nonces](https://nextjs.org/docs/app/guides/content-security-policy#nonces)
      for a CSP with `strict-dynamic`, as in the docs example. In Turbopack,
      when a `loading.tsx` (or `error` or `template`) file has a chunk that
      isn’t already loaded by a layout or client component on the page, Next
      renders a `<script>` tag for that chunk with no `nonce`. (the same chunk
      script would’ve gotten a `nonce` if it were emitted for a layout or
      page).
      
      Supersedes #92803; this is the same fix but with a new test included. 
      
      ### Why?
      
      While building out our `loading.tsx` pages, we encountered browsers
      blocking a script and reporting CSP violations, because chunk scripts
      did not properly carry a `nonce`.
      
      ### How?
      
      One-line change to bring `createComponentStylesAndScripts` to parity
      with `getLayerAssets`.
      
      ---------
      Co-authored-by: 's avatarLuke Taylor <luket@anthropic.com>
      8b037a67
    • Tobias Koppers's avatar
      Turbopack: fix output tracing include glob traversal (#98382) · 49dc4c84
      Tobias Koppers authored
      ### What?
      
      Make Turbopack's `outputFileTracingIncludes` file patterns root-relative
      and targeted during output tracing. Reject unanchored partial globs when
      code attempts directory-prefix matching. Add production coverage using a
      real pnpm-installed WASM package, plus unit coverage for anchored
      directory pruning and include-pattern expansion.
      
      ### Why?
      
      Turbopack previously treated include file patterns as unanchored partial
      matches. The directory-prefix matcher could therefore accept every
      descendant after matching the first literal segment: an exact WASM
      include under `node_modules/.pnpm` caused 2,093 `read_glob_inner`
      executions instead of traversing only its 5 directory prefixes.
      
      Unanchored patterns also cannot soundly answer whether a directory may
      contain a future match, so allowing `contains: true` with
      directory-prefix matching risks both over-traversal and missed files.
      Include behavior also differed from webpack and the documented
      project-root-relative semantics.
      
      ### How?
      
      Build anchored alternatives for each include pattern: one for the direct
      match and one for descendants of a matched directory. Anchoring lets
      `read_glob` prune unrelated directories, while the recursive alternative
      preserves existing behavior for matched directories and directory
      symlinks, including their resolved target contents.
      
      `can_match_in_directory` now fails immediately for `contains: true`,
      while direct partial matching remains supported. Route-key and exclusion
      matching continue to use direct partial matches and are unchanged.
      
      The production fixture resolves
      `lightningcss-wasm/lightningcss_node.wasm` from a real
      `lightningcss-wasm@1.28.2` dependency, avoiding assumptions about pnpm's
      store naming or patch hashes.
      
      ### Verification
      
      - `CARGO_INCREMENTAL=0 pnpm build-all`
      - `cargo fmt -p turbo-tasks-fs -p next-api -- --check`
      - `cargo test -p turbo-tasks-fs glob` (84 passed)
      - `cargo test -p next-api` (17 passed)
      - `pnpm test-start-turbo
      test/production/app-dir/output-file-tracing-includes-read-glob/output-file-tracing-includes-read-glob.test.ts
      test/production/build-trace-extra-entries-turbo/build-trace-extra-entries-turbo.test.ts
      test/production/build-trace-extra-entries-monorepo/build-trace-extra-entries-monorepo.test.ts`
      (3 passed)
      - `pnpm test-start-webpack
      test/production/app-dir/output-file-tracing-includes-read-glob/output-file-tracing-includes-read-glob.test.ts`
      - The shared fixture asserts that both bundlers include a root-relative
      exact match and exclude a nested file with the same suffix
      - Measured the exact reproduction at 5 include-specific
      `read_glob_inner` executions, down from 2,093
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet b3cefb44-e1ce-4bd6-83a9-da2f22848cad -->
      
      ---------
      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>
      49dc4c84
    • Josh Story's avatar
      test: support deploy exclusions with force gates (#98149) · 4cb54721
      Josh Story authored
      ## Summary
      
      - add static gate conditions for the deployment CI variants used by
      existing test suites
      - support `@force-gate` on parameterized `describe.each` suites
      - document and test the force-gate infrastructure needed by the
      migration
      
      This establishes the gate support used by the deployment-exclusion
      migration PRs above it.
      
      ## Verification
      
      - `pnpm typescript`
      - `pnpm jest test/unit/gate/pragma-transform.test.ts
      test/unit/gate/runtime.test.ts --runInBand`
      
      <!-- NEXT_JS_LLM -->
      4cb54721
    • Spyros Ioakeimidis's avatar
      Fix: Turbopack CSS HMR error when editing an unmounted merged CSS chunk (#94551) · 2b11d01a
      Spyros Ioakeimidis authored
      ### Fixing a bug
      
      - [x] Related issues linked using `fixes #74749`.
      - [x] Tests added (`test/development/css-hmr-unmounted-chunk`)
      - [x] N/A — removes an erroneous thrown error
      
      ### What?
      
      In `next dev` with Turbopack, editing a `.module.css` whose component
      had unmounted threw `Error: No link element found for chunk
      .../components_<hash>._.css` as an unhandled rejection. The edit
      **silently failed to apply** — you had to reload the page manually to
      see it.
      
      ### Why?
      
      `applyChunkListUpdate` handles chunk updates asymmetrically: `'added'`
      calls `loadChunkCached` (loads if missing), but `'total'` calls
      `reloadChunk`, which is rejected when no `<link>` exists. When a lazy /
      `dynamic(ssr:false)` component unmounts, `unloadChunk` removes its
      merged-aggregate `<link>` but the chunk list stays subscribed; a later
      CSS edit emits a `'total'` update for the now-unlinked aggregate →
      `reloadChunk` rejects → the `'total'` branch discards the promise →
      unhandled rejection, and the edit never applies.
      
      ### How?
      
      `reloadChunk` now loads the fresh stylesheet when no `<link>` is present
      (mirroring the `'added'` branch) instead of rejecting, so the edit
      applies without a manual reload. Regression test reproduces with a
      minimal `dynamic(ssr:false)` + 3 `React.lazy` routes fixture (red before
      — the error is thrown and the edit doesn't apply; green after).
      
      Fixes #74749
      
      <!-- NEXT_JS_LLM_PR -->
      
      ---------
      Co-authored-by: 's avatarBenjamin Woodruff <benjamin.woodruff@vercel.com>
      2b11d01a
    • Benjamin Woodruff ‮'s avatar
      Dev server: More aggresively scold users for deleting .next when we detect it… · 02a429ae
      Benjamin Woodruff authored
      Dev server: More aggresively scold users for deleting .next when we detect it while dev is running (#98253)
      
      Feedback:
      https://vercel.slack.com/archives/C03KAR5DCKC/p1788491653257349?thread_ts=1788490509.032699&cid=C03KAR5DCKC
      
      Message was added in https://github.com/vercel/next.js/pull/92135
      
      We can't detect this in most other cases where users (or agents tbh)
      delete `.next`, but in this case we can.
      02a429ae
    • Tobias Koppers's avatar
      turbo-persistence: add TURBO_PERSISTENCE_MMAP=0 to disable mmap (#97873) · 705b3269
      Tobias Koppers authored
      ## What?
      
      Add `TURBO_PERSISTENCE_MMAP=0` to disable memory-mapped persistence I/O.
      The default remains mmap; file mode reads SST blocks positionally, keeps
      block offsets in memory for random access, and reads meta/blob data
      without creating mappings.
      
      This is **1/3** in a dependent PR series.
      
      - Next: #97888
      
      ## Why?
      
      Some environments cannot use mmap reliably or have constrained virtual
      address space. The flag provides an opt-out without changing the on-disk
      format or penalizing the default mmap path.
      
      ## How?
      
      - Thread a cached `AccessMode` through database configuration.
      - Select mmap or file-backed storage independently for SST lookup,
      compaction, metadata, and blobs.
      - Keep canary's existing `ArcBytes`/`RcBytes` split, zero-copy mmap
      filters, CRC-once bitmap, fast big-endian readers, mmap cache-bypass
      behavior, and key-order handling for blocks that omit hashes.
      - Exercise lookup, restore, compaction, metadata, and blob behavior in
      both modes.
      
      ## Verification
      
      - `cargo fmt --all -- --check`
      - `cargo check -p turbo-persistence --all-targets --all-features`
      - `cargo check -p turbo-tasks-backend`
      - `cargo check -p turbo-persistence --benches`
      - `cargo test -p turbo-persistence --all-features` — 109 passed
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 088efa77-2680-49f1-8941-92bb5f92b169 -->
      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>
      705b3269
  2. 08 Sep, 2026 2 commits
    • Tobias Koppers's avatar
      Fix dev route discovery startup race (#97920) · e953bdaa
      Tobias Koppers authored
      ### What?
      
      Fix a dev-server startup race that could temporarily publish an empty
      Pages Router route set when Watchpack's first filesystem aggregation
      arrived before its route-directory scan completed.
      
      The dev bundler now snapshots the initial `pages/` and `app/` files
      before starting the watcher. During startup it ignores Watchpack
      aggregations that are missing an existing snapshot page file, so it does
      not publish route definitions or errors from a partial filesystem view.
      Empty route directories are detected from the same snapshot rather than
      from a separate callback that could race or mistake a read error for an
      empty directory.
      
      The `next-head` e2e fixture now delays Watchpack's initial `pages/` scan
      in development mode, deterministically covering the failing ordering
      while preserving every existing head-tag assertion and non-dev test
      mode.
      
      ### Why?
      
      PR #97905's build-and-test run 32911367895, job 98006962799 (`test cache
      components dev (6/6) / build`) exposed this as a flaky
      `test/e2e/next-head/index.test.ts` failure. In the raw job log around
      lines 3135–3305, retry 0 reported `Ready in 420ms` and then served `/`
      as a 404 four times. The returned document contained the `_error` page
      title (`404: This page could not be found`) and `pages__error` chunks,
      so four head-tag assertions failed downstream. Retry 1 passed about nine
      seconds later.
      
      The first Watchpack aggregation could run route discovery before
      `pages/index.js` appeared in `getTimeInfoEntries()`. That published no
      page route definitions and released the request handler, causing `/` to
      fall through to `_error` until a later aggregation repaired the route
      table. This change waits to publish any initial route state until
      Watchpack has a complete view, rather than adding request retries,
      sleeps, or broader timeouts.
      
      ### How?
      
      - Snapshot route directories once before watcher startup, tolerating a
      directory removed during boot so Watchpack can report the removal
      normally.
      - Ignore incomplete startup aggregations until Watchpack observes every
      snapshot page that still exists, with a 30-second safety deadline so an
      unwatchable file cannot stall startup.
      - Drive the empty-directory startup path from the snapshot, removing the
      error-swallowing `fs.readdir` race.
      - Delay the first Watchpack `pages/` scan in a separate dev-only
      route-discovery case and assert that the injection fired. The focused
      test reproduced `GET / 404` before the fix and returns `GET / 200` with
      the fix.
      - Preserve the original five `next/head` test cases unchanged; validate
      the app/pages conflict path separately.
      
      ### Verification
      
      - Exact CI environment: `__NEXT_CACHE_COMPONENTS=true
      __NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS=true
      __NEXT_EXPERIMENTAL_SERVER_COMPONENTS_HMR_CANCELLATION=true
      NEXT_EXTERNAL_TESTS_FILTERS=test/cache-components-tests-manifest.json
      NEXT_TEST_MODE=dev IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 pnpm
      test-dev-turbo test/e2e/next-head/index.test.ts` — 5/5 passed
      - `IS_WEBPACK_TEST=1 NEXT_TEST_MODE=dev pnpm test-dev-webpack
      test/e2e/next-head/index.test.ts` — 5/5 passed
      - `pnpm --filter=next types`
      - `pnpm --filter=next build`
      - Prettier, ESLint, and `git diff --check`
      
      <!-- NEXT_JS_LLM -->
      
      
      <!-- fleet 4ac891b6-2d24-4103-95bf-9daf04359e3f -->
      
      ---------
      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>
      e953bdaa
    • next-js-bot[bot]'s avatar
      v16.4.0-canary.22 · 6cb63960
      next-js-bot[bot] authored
      6cb63960