1. 06 Mar, 2026 15 commits
    • nextjs-bot's avatar
      v16.2.0-canary.83 · 12c8715b
      nextjs-bot authored
      12c8715b
    • Andrew Clark's avatar
      fix: Don't fall through to catch-all when static child subtree doesn't match (#90957) · f27b4928
      Andrew Clark authored
      When matching a URL against the known route trie, if a URL part matches
      a static child but the remaining parts don't resolve within that child's
      subtree, the algorithm incorrectly falls back to a dynamic catch-all
      sibling at the same level. This causes the catch-all to consume the
      already-matched static part plus the remaining parts, producing a
      synthetic entry for the wrong route.
      
      For example, given routes `/dashboard/settings/profile` and
      `/dashboard/[...catchall]`, navigating to `/dashboard/settings/profile`
      could incorrectly match the catch-all with params `["settings",
      "profile"]` instead of the intended static route.
      
      The fix treats the static child match as authoritative: if a real
      (non-placeholder) static child exists but its subtree can't resolve the
      remaining URL parts, bail out to server resolution rather than trying
      the dynamic sibling. This is safe because it just means an extra network
      request for routes whose subtree hasn't been fully discovered.
      f27b4928
    • zoomdong's avatar
      2c2dd5fe
    • Jude Gao's avatar
      [Evals] Standardize Evals in Next.js (#90883) · 0921733a
      Jude Gao authored
      Fixtures now live next to the code they test, like e2e. `pnpm eval
      <name>` packs the local `next` build, generates baseline + agents-md
      experiment configs on the fly, and runs both in a sandbox. The agents-md
      variant drops an `AGENTS.md` that points the agent at the bundled docs
      in `node_modules/next/dist/docs/` — comparing the two variants tells you
      whether shipping a doc actually changes agent behavior.
      
      `run-evals.js` mirrors `run-tests.js`: pack once, pass the tarball path
      to the child via `NEXT_EVAL_TARBALL` env, forward flags. We only pack
      `next`, not the whole workspace — the sandbox is remote Linux, so a
      local `@next/swc` darwin binary wouldn't run there anyway; the sandbox
      downloads the right one at runtime. The experiment config uses `sandbox:
      'auto'`, which picks Vercel sandboxes when credentials are present and
      falls back to local Docker otherwise, so external contributors can run
      the same evals with just Docker + `ANTHROPIC_API_KEY`.
      
      `experiments/` is generated fresh each run and gitignored so we don't
      maintain N committed config files that differ by one line. Fixture code
      is excluded from eslint since it's deliberately imperfect code for
      agents to fix, and `EVAL.ts` uses vitest rather than jest. Fixture
      `package.json` files use `"next": "^16"` rather than a pinned canary so
      agents reading `package.json` to infer capabilities aren't misled by a
      stale version string; the tarball install overlays it regardless.
      
      next-evals-oss stays as the full benchmark runner for nextjs.org/evals;
      it'll pull fixtures from here instead of keeping its own copy.
      0921733a
    • Zack Tanner's avatar
      re-introduce partial fallback -> route upgrading (#89063) · af48a183
      Zack Tanner authored
      In https://github.com/vercel/next.js/pull/69282, we landed support for
      Partial Fallback Prerendering. The intention behind this feature was to
      be able to upgrade from a partial fallback (essentially the UI produced
      when `await params` is dynamic, ie the param was not part of
      `generateStaticParams` at build time) to a route shell (when the param
      values are filled in, and thus we can prerender more of the page).
      
      It was reverted in https://github.com/vercel/next.js/pull/79258 because
      we didn't add first-class support to this in the build output API and
      the necessary infrastructure changes to perform similar behavior that
      this PR does to trigger a background revalidation with params filled in.
      
      This re-lands the feature in Next.js now that upstream support landed
      (https://github.com/vercel/vercel/pull/14703,
      https://github.com/vercel/vercel/pull/15338, and Vercel infra changes
      which are rolling out)
      af48a183
    • Hendrik Liebau's avatar
      Cache runtime data for partially static pages on initial load (resume) (#90888) · 0268c7b3
      Hendrik Liebau authored
      When a partially static page with `unstable_instant: { prefetch:
      'runtime' }` is loaded as initial HTML (PPR resume), the server now
      spawns a runtime prerender after the resume render fills the caches,
      embedding the result as the `p` field on the `InitialRSCPayload`. The
      client extracts this stream during hydration via
      `processRuntimePrefetchStream` and writes the data into the segment
      cache.
      
      This mirrors the existing navigation path where
      `generateStagedDynamicFlightRenderResult` embeds the runtime prefetch
      stream in the `NavigationFlightResponse`. Both paths reuse the same
      `spawnRuntimePrefetchWithFilledCaches` function (renamed from
      `spawnRuntimePrefetchDuringNavigation` since it is no longer specific to
      navigations).
      0268c7b3
    • Zack Tanner's avatar
      preserve allowQuery for partial fallback shells (#90887) · cb54d203
      Zack Tanner authored
      Analogous change to https://github.com/vercel/vercel/pull/15338, but for the new Next.js adapter API.
      
      This updates only allowQuery for fallback HTML when the route is a true partialFallback (PPR fallback with postponed state) and cache components is enabled. For all other fallback cases, behavior stays the same as today (allowQuery is cleared to [] for shared fallback caching).
      
      This change is needed because partial-fallback shells can be param-specific, so collapsing them to one shared fallback cache key can serve the wrong shell across params and block correct upgrade behavior. Gating this behind partialFallback lets us roll out the new behavior safely and independently, without changing legacy fallback semantics for non-partial paths.
      cb54d203
    • JJ Kasper's avatar
      docs: explain deploy test custom scripts (#90966) · d2525d76
      JJ Kasper authored
      ## Summary
      - document how to use custom deploy, logs, and cleanup scripts with the
      deploy test workflow
      - describe the expected stdout/log marker contract for custom scripts
      - keep the examples generic to adapter implementations
      
      ---------
      Co-authored-by: 's avatarVercel <vercel[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
      d2525d76
    • Hendrik Liebau's avatar
      Fix preview version in `window.next.version` for PR builds (#90937) · 87a8fb2f
      Hendrik Liebau authored
      Preview builds served via `vercel-packages.vercel.app` were showing the
      published canary version instead of the PR-specific preview version.
      This happened because `create-preview-tarballs.js` updated
      `package.json` after the build, but the version was already baked into
      the compiled `dist/` files by `setNextVersion` in `taskfile-swc.js`.
      
      This extracts the version computation from `create-preview-tarballs.js`
      into a new `set-preview-version.js` script that runs before `pnpm run
      build`, so the compiled output naturally includes the correct version.
      `create-preview-tarballs.js` now reads the version from
      `packages/next/package.json` instead of computing it independently.
      
      ## Test Plan
      
      1. Create a new app: `pnpm create next-app@canary`
      2. Install the preview build from this PR: `pnpm i
      https://vercel-packages.vercel.app/next/commits/06681c21e886a97e39d277808780884151c00318/next`
      3. Run `pnpm dev` and inspect `next.version` in DevTools — should show
      `16.2.0-preview-06681c21-20260306` instead of the canary version
      87a8fb2f
    • Niklas Mischkulnig's avatar
      Turbopack: pass reference type to CustomModuleType (#90814) · 07df7fa0
      Niklas Mischkulnig authored
      No reason to restrict it to `ReferenceType::EcmaScriptModules(EcmaScriptModulesReferenceSubType::ImportPart(part))`
      07df7fa0
    • Hendrik Liebau's avatar
      Add `experimental.cachedNavigations` feature flag (#90928) · d08f4dc0
      Hendrik Liebau authored
      The recent Cached Navigations feature introduced navigation-level
      caching into the segment cache, where static and dynamic RSC data from
      navigations and initial HTML loads is cached so that repeat visits can
      be served instantly. This feature is currently gated behind
      `cacheComponents`, meaning it activates for all projects that enable
      Cache Components.
      
      This change introduces a new `experimental.cachedNavigations` flag that
      independently controls the Cached Navigations behavior. The flag
      defaults to `false` so we can investigate potential regressions that the
      feature might have introduced without affecting the broader Cache
      Components functionality.
      
      The flag requires `cacheComponents` to also be enabled and throws a
      configuration error if `cachedNavigations` is set without it. On the
      server, the staged rendering paths in `app-render.tsx` (both RSC request
      handling and initial HTML rendering) now check `cacheComponents &&
      cachedNavigations` before producing staged responses. On the client,
      `process.env.__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS` is used alongside
      `process.env.__NEXT_CACHE_COMPONENTS` for compile-time dead code
      elimination in the stream tee (`app-index.tsx`) and the response
      processing (`fetch-server-response.ts`).
      
      The cached navigations test suite enables the flag via `next.config.ts`,
      and the Cache Components CI jobs export
      `__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS=true` to maintain test coverage.
      d08f4dc0
    • Niklas Mischkulnig's avatar
      Turbopack: CompileTimeDefineValue numbers and regex (#90934) · 73b44a18
      Niklas Mischkulnig authored
      - Number(f64) instead of Number(RcStr)
      - Add BigInt
      - Add Regex
      73b44a18
    • Josh Story's avatar
      Rewrite instant validation to use depth-based URL boundary discovery (#90905) · 60a847b0
      Josh Story authored
      Instead of pre-planning validation tasks by walking the tree and
      accumulating `navigationParents`, the new implementation drives
      validation by URL depth. Starting from the deepest URL segment and
      working backwards, it builds a combined payload at each depth where the
      boundary between shared (already-mounted) and new (being-navigated-to)
      content is determined by counting URL-consuming segments. If the new
      subtree at that depth contains any `unstable_instant` configs, the
      payload is validated. If not, it moves to the next shallower depth.
      
      This approach has several advantages over the task-based model:
      
      - Route group layouts no longer create spurious navigation boundaries —
      they don\`t consume URL depth, so they naturally share the boundary of
      their parent URL segment
      - The `requiresInstantUI` requirement propagates correctly through the
      tree: a local `false` config opts the subtree out, a non-false config
      opts it in, and no config defers to the OR-union of children slots
      - Both the static-stage and runtime-retry payloads are built in a single
      tree walk, avoiding the separate retry pass
      - The `<head>` stage correctly uses Runtime when any segment in the new
      tree uses runtime prefetch
      60a847b0
    • nextjs-bot's avatar
      v16.2.0-canary.82 · d1fcd201
      nextjs-bot authored
      d1fcd201
    • Tobias Koppers's avatar
      Set DontFork and Unmergeable on all mmap sites in turbo-persistence (#90941) · 83ae8ad6
      Tobias Koppers authored
      ## Summary
      
      - Add `madvise(MADV_DONTFORK)` and `madvise(MADV_UNMERGEABLE)` to all mmap sites in turbo-persistence
      - Extract a shared `advise_mmap_for_persistence` helper into a dedicated `mmap_helper` module
      
      ## Why
      
      `read_blob` in `db.rs` already correctly sets `DontFork` and `Unmergeable` on its mmap, but three other mmap sites were missing these flags:
      
      - **`static_sorted_file.rs`** (`open_internal`) — SST file mmaps used for lookups and compaction
      - **`meta_file.rs`** (`open_internal`) — meta file mmaps storing AMQF filters and SST metadata
      - **`sst_inspect.rs`** (`analyze_sst_file`) — diagnostic tool mmap
      
      `MADV_DONTFORK` prevents mmap regions from being copied into child processes on `fork()`, avoiding unnecessary memory duplication and potential SIGBUS issues if the parent unmaps before the child accesses the page. `MADV_UNMERGEABLE` opts the pages out of KSM (Kernel Same-page Merging), avoiding the overhead of scanning these pages for deduplication since they contain unique compressed data.
      
      Both flags are Linux-only (`#[cfg(target_os = "linux")]`), matching the existing pattern in `read_blob`.
      
      ## Implementation
      
      Rather than duplicating `#[cfg(target_os = "linux")]` madvise calls at each mmap site, a shared helper `advise_mmap_for_persistence()` is extracted into `src/mmap_helper.rs`. The function applies both flags on Linux and is a no-op on other platforms. All four mmap sites (`db.rs`, `static_sorted_file.rs`, `meta_file.rs`, `sst_inspect.rs`) now call this single helper.
      
      ## Test Plan
      
      - `cargo check -p turbo-persistence` passes
      - `cargo fmt` clean
      - No behavioral change on non-Linux platforms (flags are gated behind `#[cfg(target_os = "linux")]`)
      83ae8ad6
  2. 05 Mar, 2026 14 commits
    • nextjs-bot's avatar
      v16.2.0-canary.81 · 16206a7f
      nextjs-bot authored
      16206a7f
    • Hendrik Liebau's avatar
      Revert legacy PPR removal (#90948) · c2bba0ea
      Hendrik Liebau authored
      This caused regressions. Apparently it was not a clean removal.
      c2bba0ea
    • Tobias Koppers's avatar
      Prefix pr-status replies with 🤖 emoji (#90943) · 2544467b
      Tobias Koppers authored
      ### What?
      
      Prefixes replies posted by `scripts/pr-status.js` with the `🤖` (🤖) emoji.
      
      ### Why?
      
      When the pr-status script replies to PR review threads, there's no visual indicator that the reply was generated by AI rather than a human. Adding the robot emoji makes it immediately clear.
      
      ### How?
      
      One-line change in the `replyToThread()` function in `scripts/pr-status.js` that prepends `🤖 ` to the reply body before posting it via the GitHub GraphQL API.
      2544467b
    • Benjamin Woodruff's avatar
      Turbopack: Annotate ReadVcFuture as must_use instead of annotating functions… · 9d0fbf13
      Benjamin Woodruff authored
      Turbopack: Annotate ReadVcFuture as must_use instead of annotating functions that return it (#90839)
      
      It's a little less error-prone if it's in one place (on the type) than in many (on the functions). I also added it to `ReadRawVcFuture`.
      
      https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute
      
      - **Are these equivalent?** Yes.
      - **The** **`Future`** **trait already has this annotation, why do we need it on the type?** The annotation on the trait only applies if the function returns `impl Future` or `dyn Future`. Our functions return the named type.
      9d0fbf13
    • Benjamin Woodruff's avatar
      Turbopack: Fix some eventually consistent reads at the top level in dev-server… · 73049d6f
      Benjamin Woodruff authored
      Turbopack: Fix some eventually consistent reads at the top level in dev-server and snapshot tests (#90792)
      
      This fixes
      
      ```
      UPDATE=1 cargo test -p turbopack-tests
      ```
      
      when a snapshot test output is modified or deleted.  
        
      We must get the `Effects` inside of an operation, as that involves reading `Vc`s, but then we should apply them outside of the operation (to guarantee that they only run once). The Next.js code follows a similar pattern here.
      73049d6f
    • Luke Sandberg's avatar
      Batch require cache deletion to avoid quadratic scanning (#90625) · 3beb4665
      Luke Sandberg authored
      ### What?
      
      Rewrites `deleteFromRequireCache()` in `packages/next/src/server/dev/require-cache.ts` to accept an array of file paths and perform a single scan of `require.cache`, instead of one full scan per file. Adds a `deleteCacheBatch()` export and updates all three batch call sites to use it.
      
      ### Why?
      
      During server-side HMR, `deleteCache()` is called in loops — once per server path in the turbopack hot-reloader (5-20 files), up to 15 times per `writeManifests()` in the manifest-loader, and 2 + N times (runtime chunks + page entries) in the webpack plugin's `afterEmit` hook. Each call scans the **entire** `require.cache` to clean up parent-child references, making the overall cost O(N × C) where C is the cache size. In large apps with thousands of cached modules, this becomes a meaningful bottleneck on every HMR update.
      
      ### How?
      
      **Core change (`require-cache.ts`):** `deleteFromRequireCache` now accepts `string[]`. It resolves all paths upfront, collects target modules into a `Set<NodeModule>`, then does one scan of `require.cache` using `Set.has()` (O(1) lookup) to filter children arrays. For single-item callers (`deleteCache`), the overhead of a 1-element Set is negligible.
      
      **Call site updates:**
      - **`hot-reloader-turbopack.ts`**: Collects files to delete into an array during the `serverPaths` loop, calls `deleteCacheBatch()` once after. `clearModuleContext` stays per-file (separate system).
      - **`manifest-loader.ts`**: Adds `pendingCacheDeletes` array to `TurbopackManifestLoader`. All ~15 `deleteCache()` calls in `write*` methods become `push()` calls. Flushed at the end of `writeManifests()` with a single `deleteCacheBatch()`. Moving cache deletion to after all `writeFileAtomic` calls is safe (synchronous code, no interleaving) and slightly better (new files on disk before cache is cleared).
      - **`nextjs-require-cache-hot-reloader.ts`** (webpack): Batches the `afterEmit` hook — collects runtime chunk + page entry paths, calls `deleteCacheBatch()` once. The `assetEmitted` tap callback stays as individual `deleteCache()`.
      
      **Theoretical improvement:**
      
      | Call Site | Before (cache scans) | After | Improvement |
      |-----------|---------------------|-------|-------------|
      | turbopack `clearRequireCache` | N (5-20) | 1 | 5-20× fewer scans |
      | manifest-loader `writeManifests` | up to 15 | 1 | up to 15× fewer scans |
      | webpack `afterEmit` | 2 + page count | 1 | up to 50× fewer scans |
      
      ### Benchmark
      
      Tested with a generated 250-route app with 50 API route handlers importing server external packages (zod, lodash, express, pg, ioredis) plus middleware. API route handlers are key because unlike bundled app-router pages, they create real `require.cache` depth with native Node.js module loading.
      
      **Results (steady-state, 18 paths / 7 found / 781 nodes / ~1800 edges):**
      
      | Mode | Time per batch |
      |------|---------------|
      | **Batched** (1 scan) | **~0.24ms** |
      | **Unbatched** (18 individual scans) | **~0.70ms** |
      | **Speedup** | **~3×** |
      
      Raw data (representative samples):
      
      ```
      # Batched (1 scan of require.cache)
      [PERF] deleteCacheBatch(batch=true): 18 paths (7 found), 781 nodes, 1772 edges, 0.283ms
      [PERF] deleteCacheBatch(batch=true): 18 paths (7 found), 781 nodes, 1800 edges, 0.250ms
      [PERF] deleteCacheBatch(batch=true): 18 paths (7 found), 781 nodes, 1912 edges, 0.283ms
      
      # Unbatched (18 individual scans)
      [PERF] deleteCacheBatch(batch=false): 18 paths (7 found), 781 nodes, 1772 edges, 0.671ms
      [PERF] deleteCacheBatch(batch=false): 18 paths (7 found), 781 nodes, 1800 edges, 0.649ms
      [PERF] deleteCacheBatch(batch=false): 18 paths (7 found), 781 nodes, 1912 edges, 0.716ms
      ```
      
      The speedup scales with cache complexity — in production apps with more server externals (ORMs, validation libs, etc.) the cache would be larger and the improvement proportionally greater. With only bundled app-router pages (few edges in require.cache graph), the difference is negligible since most of the graph complexity comes from native Node.js module loading.
      3beb4665
    • Shu Ding's avatar
      Update `@vercel/og` and `satori` vendors (#90933) · dc57cde3
      Shu Ding authored
      The new `@vercel/og` and `satori` include many improvements:
      - 2~20x faster image generation (`ImageResponse` API) by using Sharp for
      rasterization, and optimized Satori core
      - Better CSS/SVG coverage:
        - https://github.com/vercel/satori/issues/736
        - https://github.com/vercel/satori/pull/734
        - https://github.com/vercel/satori/pull/733
        - https://github.com/vercel/satori/pull/732
        - https://github.com/vercel/satori/issues/728
        - https://github.com/vercel/satori/issues/724
        - https://github.com/vercel/satori/pull/717
        - https://github.com/vercel/satori/pull/718
        - https://github.com/vercel/satori/pull/719
      - Updated layout engine (https://github.com/vercel/satori/pull/689):
        - Support for `box-sizing`
        - Support for `display: contents`
        - Support for `position: static`
        - Support for `align-content: space-evenly`
        - Better support for `position: absolute`
        - Support for percentage values for `gap`
      - Noto Sans → Geist Sans
      dc57cde3
    • Andrew Clark's avatar
      Fix prefetch inlining build failure with dynamic routes (#90899) · 747d3dc4
      Andrew Clark authored
      When prefetchInlining is enabled, the segment data collection returns a
      special key for the inlined response. Previously this key was
      `/_inlined`, but the build validation code in
      `packages/next/src/build/index.ts` expects segment paths to contain
      `__PAGE__`. This caused builds to fail with "Invariant: missing __PAGE__
      segmentPath" for any dynamic route using prefetchInlining.
      
      Fix by using the same `PAGE_SEGMENT_KEY` (`__PAGE__`) constant for the
      inlined segment response key, matching what the build code already
      expects. This is consistent since the inlined response serves the same
      role as the per-page segment data — it just bundles all segments
      together.
      
      Closes #90850
      Co-authored-by: 's avatarBen Salmon <ben.salmon@daylightgroup.nz>
      Co-authored-by: 's avatarBen Salmon <ben.salmon@daylightgroup.nz>
      747d3dc4
    • Niklas Mischkulnig's avatar
      tests: Use pnpm dlx to install latest CLI version (#90923) · beb222e8
      Niklas Mischkulnig authored
      Hopefully improve flakeyness
      beb222e8
    • Joseph's avatar
      Uncached data suspense issue (#90450) · 75af3bbd
      Joseph authored
      <!-- Thanks for opening a PR! Your contribution is much appreciated.
      To make sure your PR is handled as smoothly as possible we request that
      you follow the checklist sections below.
      Choose the right checklist for the change(s) that you're making:
      
      ## For Contributors
      
      ### Improving Documentation
      
      - Run `pnpm prettier-fix` to fix formatting issues before opening the
      PR.
      - Read the Docs Contribution Guide to ensure your contribution follows
      the docs guidelines:
      https://nextjs.org/docs/community/contribution-guide
      
      ### Fixing a bug
      
      - Related issues linked using `fixes #number`
      - Tests added. See:
      https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Adding a feature
      
      - Implements an existing feature request or RFC. Make sure the feature
      request has been accepted for implementation before opening a PR. (A
      discussion must be opened, see
      https://github.com/vercel/next.js/discussions/new?category=ideas)
      - Related issues/discussions are linked using `fixes #number`
      - e2e tests added
      (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
      - Documentation added
      - Telemetry added. In case of a feature if it's used or not.
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      
      ## For Maintainers
      
      - Minimal description (aim for explaining to someone not on the team to
      understand the PR)
      - When linking to a Slack thread, you might want to share details of the
      conclusion
      - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
      - Add review comments if necessary to explain to the reviewer the logic
      behind a change
      
      ### What?
      Added a new section "Opting Into Fully Dynamic Rendering" to
      `errors/blocking-route.mdx`.
      
      ### Why?
      To surface the "Suspense over body" pattern as a general solution for
      "Uncached data or connection() was accessed outside of <Suspense>"
      errors. This pattern was previously only documented in
      `next-prerender-dynamic-viewport.mdx` but is relevant to all blocking
      route errors, providing a clear opt-out for users who want fully dynamic
      rendering without granular Suspense boundaries. This directly addresses
      a common user query.
      
      ### How?
      Added a new section with a code example demonstrating wrapping the root
      `<html>` in `<Suspense>` within `app/layout.tsx`.
      
      Closes NEXT-
      Fixes #
      
      -->
      
      ---
      [Slack
      Thread](https://vercel.slack.com/archives/C07BS1WEYAZ/p1771948980142259?thread_ts=1771948980.142259&cid=C07BS1WEYAZ)
      
      <p><a
      href="https://cursor.com/agents/bc-a1a4ed9d-03cd-4241-b057-748fbf9487a9"><picture><source
      media="(prefers-color-scheme: dark)"
      srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
      media="(prefers-color-scheme: light)"
      srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
      alt="Open in Web" width="114" height="28"
      src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
      href="https://cursor.com/background-agent?bcId=bc-a1a4ed9d-03cd-4241-b057-748fbf9487a9"><picture><source
      media="(prefers-color-scheme: dark)"
      srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
      media="(prefers-color-scheme: light)"
      srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
      alt="Open in Cursor" width="131" height="28"
      src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</p>
      
      ---------
      Co-authored-by: 's avatarCursor Agent <cursoragent@cursor.com>
      Co-authored-by: 's avatarJoseph <icyJoseph@users.noreply.github.com>
      75af3bbd
    • Jimmy Lai's avatar
      Loading layout docs update (#90787) · dfbc3dc6
      Jimmy Lai authored
      <!-- Thanks for opening a PR! Your contribution is much appreciated.
      To make sure your PR is handled as smoothly as possible we request that
      you follow the checklist sections below.
      Choose the right checklist for the change(s) that you're making:
      
      ## For Contributors
      
      ### Improving Documentation
      
      - Run `pnpm prettier-fix` to fix formatting issues before opening the
      PR.
      - Read the Docs Contribution Guide to ensure your contribution follows
      the docs guidelines:
      https://nextjs.org/docs/community/contribution-guide
      
      ### Fixing a bug
      
      - Related issues linked using `fixes #number`
      - Tests added. See:
      https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Adding a feature
      
      - Implements an existing feature request or RFC. Make sure the feature
      request has been accepted for implementation before opening a PR. (A
      discussion must be opened, see
      https://github.com/vercel/next.js/discussions/new?category=ideas)
      - Related issues/discussions are linked using `fixes #number`
      - e2e tests added
      (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
      - Documentation added
      - Telemetry added. In case of a feature if it's used or not.
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      
      ## For Maintainers
      
      - Minimal description (aim for explaining to someone not on the team to
      understand the PR)
      - When linking to a Slack thread, you might want to share details of the
      conclusion
      - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
      - Add review comments if necessary to explain to the reviewer the logic
      behind a change
      
      ### What?
      This PR updates the documentation to clarify the interaction between
      `loading.js` and `layout.js`.
      
      ### Why?
      To address a common point of confusion and potential blocking navigation
      issues when layouts are dynamic. It provides clear guidance on how
      `loading.js` behaves relative to layouts and how to use `<Suspense>` for
      dynamic layout parts.
      
      ### How?
      - Added a "Good to know" callout in `loading.mdx` explaining that
      `loading.js` does not wrap the layout.
      - Introduced a new "Interaction with `loading.js`" section under Caveats
      in `layout.mdx`, including an explanation and a code example for
      wrapping dynamic layout components with `<Suspense>`.
      - Added a brief "Good to know" callout in `fetching-data.mdx` for
      consistency.
      
      Closes NEXT-
      Fixes #
      -->
      
      ---
      [Slack
      Thread](https://vercel.slack.com/archives/C05KYT5S9FF/p1772239839900129?thread_ts=1772239839.900129&cid=C05KYT5S9FF)
      
      <p><a
      href="https://cursor.com/agents/bc-d69fb736-2a00-5f68-9e28-9b31c194f12a"><picture><source
      media="(prefers-color-scheme: dark)"
      srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
      media="(prefers-color-scheme: light)"
      srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
      alt="Open in Web" width="114" height="28"
      src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
      href="https://cursor.com/background-agent?bcId=bc-d69fb736-2a00-5f68-9e28-9b31c194f12a"><picture><source
      media="(prefers-color-scheme: dark)"
      srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
      media="(prefers-color-scheme: light)"
      srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
      alt="Open in Cursor" width="131" height="28"
      src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</p>
      
      ---------
      Co-authored-by: 's avatarCursor Agent <cursoragent@cursor.com>
      Co-authored-by: 's avatarJoseph Chamochumbi <joseph.chamochumbi@vercel.com>
      Co-authored-by: 's avatarDelba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
      dfbc3dc6
    • nextjs-bot's avatar
    • Tobias Koppers's avatar
      Turbopack: Tree shaking fixes and code organization (#89295) · ad030d78
      Tobias Koppers authored
      ## Summary
      
      A series of bug fixes, refactors, and code organization improvements to Turbopack's tree shaking and side effect optimization:
      
      - **Fix `ModulePart` handling for `FreeVarReference::EcmaScriptModule`** — pass `ModulePart` correctly so free variable references resolve to the right module part
      - **Extract `EcmascriptModuleRenameModule`** — split the rename/reexport logic (`RenamedExport`, `RenamedNamespace`) out of `EcmascriptModuleFacadeModule` into a dedicated `rename` module, shared between side effects optimization and tree shaking
      - **Simplify `EcmascriptModuleFacadeModule`** — now only handles the `Facade` case (locals + reexports), no longer overloaded with rename variants
      - **Reorganize tree shaking code** — moved `asset.rs` → `part/module.rs`, `chunk_item.rs` → `part/chunk_item.rs` + `side_effects/chunk_item.rs`, `side_effect_module.rs` → `side_effects/module.rs` for clearer separation between part modules and side effect modules
      - **Use `EsmExport` in `FindExportFromReexportsResult`** — reduces code duplication by reusing the existing `EsmExport` enum
      - **Minor simplifications** — code deduplication, reordered checks, and general cleanup
      ad030d78
    • Luke Sandberg's avatar
      Add trace spans for turbopack persistence in .next/trace (#90397) · 286a73f8
      Luke Sandberg authored
      ## Summary
      
      - Add a generic `TraceEvent` compilation event type that carries a name, wall-clock timing, and arbitrary attributes
      - Emit `TraceEvent` from Turbopack's Rust backend for cache persistence and compaction operations
      - Expose `eventJson` on compilation events through the NAPI bridge
      - Record `turbopack-persistence` and `turbopack-compaction` trace spans in `.next/trace` with memory usage snapshots, in both dev and build workflows
      
      ## Details
      
      Turbopack persistence and compaction operations were invisible in `.next/trace`. The only signal was a console log for operations exceeding 10s.
      
      A new generic `TraceEvent` type replaces the need for per-operation event structs. It carries a name, start/end wall-clock timestamps, and a `Vec` of key-value attributes. On the JS side, `backgroundLogCompilationEvents` handles all `TraceEvent`s with a single code path — creating trace spans via `manualTraceChild` and recording memory usage snapshots. Adding new traced operations requires only a few lines of Rust and zero JS changes.
      
      At @bgw's suggestion, I considered integrating as a `tracing_subscriber::Layer` to automatically forward spans to the compilation event system, but this ended up requiring quite a bit of code (a new subscriber, 'target' impl, span lifecycle management, new crate dependencies) for what is currently just 2 events, and we don't really anticipate adding more.
      
      ## Test plan
      
      - [x] Integration test in `test/e2e/filesystem-cache` verifying `turbopack-persistence` spans exist with correct attributes
      - [x] `pnpm test-dev-turbo test/e2e/filesystem-cache`
      - [x] `pnpm test-start-turbo test/e2e/filesystem-cache`
      286a73f8
  3. 04 Mar, 2026 11 commits