1. 12 Mar, 2026 22 commits
  2. 11 Mar, 2026 18 commits
    • nextjs-bot's avatar
      v16.2.0-canary.93 · b4efbdbd
      nextjs-bot authored
      b4efbdbd
    • JJ Kasper's avatar
      Preserve RSC metadata in Proxy request with skipProxyUrlNormalize (#91213) · bf56c712
      JJ Kasper authored
      ## Summary
      - preserve Flight/RSC headers on the Proxy request instance when URL
      normalization is skipped (`skipProxyUrlNormalize`)
      - preserve the `_rsc` query on the request URL in that same mode so
      custom proxy logic can access it
      - document this behavior in the Proxy API docs, including guidance for
      `NextResponse.rewrite()` vs custom `fetch` rewrites
      - add an e2e regression in `skip-trailing-slash-redirect` to verify
      middleware receives `_rsc` and all RSC headers on the request instance
      
      ## Testing
      - `NEXT_SKIP_ISOLATE=1 NEXT_TEST_MODE=dev pnpm testheadless
      test/e2e/skip-trailing-slash-redirect/index.test.ts`
      bf56c712
    • Benjamin Woodruff's avatar
      docs(turbopack): Merge the contents of the "cells" page in the mdbook with our rustdocs (#91126) · 88501630
      Benjamin Woodruff authored
      Merges the content from https://turbopack-rust-docs.vercel.sh/turbo-engine/cells.html into our rustdocs. I also tried fixing the wording of a few things for accuracy, and adding a bit more detail where warranted.
      
      Mostly, this modified our `Vc` documentation.
      
      Rendering of `Vc` page:
      
      ![Screenshot 2026-03-09 at 17-40-05 Vc in turbo_tasks - Rust.png](https://app.graphite.com/user-attachments/assets/6c713d93-5916-43ba-96e9-b5d1b647b8d1.png)
      88501630
    • Niklas Mischkulnig's avatar
      Fix syntax contexts in server action transform (#91210) · 196ed2b8
      Niklas Mischkulnig authored
      ```
      let x: Ident = IdentName::new(name, span).into();
      ```
      should never be done. It uses `SyntaxContext::default()` for the Ident. So from swc's perspective, you are referring to a different variable than you think. When constructing an `Ident`, you should usually always provide a SyntaxContext.
      
      I think this would pose a problem in Webpack because it serializes it into a code string again, but for Turbopack these SyntaxContext are important.
      196ed2b8
    • Luke Sandberg's avatar
      remove worktrees accidentally committed in #90166 (#91215) · 9848d228
      Luke Sandberg authored
      🤦‍♂️
      9848d228
    • Sam Selikoff's avatar
      Adds a Start button to the Instant Navs panel to initiate inspection … (#91216) · 5920e9db
      Sam Selikoff authored
      …of client navs. Allows the initial screen to be dismissed without
      reloading the app.
      
      
      https://github.com/user-attachments/assets/56b08c57-bd78-4d38-875d-244a450b7325
      5920e9db
    • xusd320's avatar
      fix(turbopack): unref ThreadsafeFunctions to allow Node.js exit after build (#91107) · b1db0269
      xusd320 authored
      ## What?
      
      Calls `unref()` on the `ThreadsafeFunction`s created in
      `NapiNextTurbopackCallbacks::from_js` (`throw_turbopack_internal_error`
      and `on_before_deferred_entries`).
      
      ## Why?
      
      These `ThreadsafeFunction`s are not unref'd, which means they keep the
      Node.js event loop alive even after `project_shutdown` completes.
      
      Currently this doesn't cause a visible hang in Next.js because turbopack
      runs inside a worker thread (via `packages/next/src/lib/worker.ts`), and
      the worker thread is terminated externally. However, if turbopack were
      ever run in a child process or directly in the main process, the build
      would hang indefinitely after completion — the Rust side of
      `stop_and_wait()` finishes, but the Node.js process never exits because
      the ref'd `ThreadsafeFunction`s prevent the event loop from draining.
      This happened in `utoo`, caused some CI hang forever, the same fix
      commit:
      https://github.com/utooland/utoo/pull/2670/changes/9e8fd08e84470dce6ac59e976db1b556ce7fece8.
      
      This fix makes the shutdown behavior more robust by following the same
      pattern already used in `register_worker_scheduler` in
      `turbopack-node/src/worker_pool/worker_thread.rs`, where both creator
      and terminator `ThreadsafeFunction`s are explicitly unref'd.
      
      ## How?
      
      - Added `Env` parameter to `NapiNextTurbopackCallbacks::from_js()`
      - Called `unref(&env)` on both `throw_turbopack_internal_error` and
      `on_before_deferred_entries` after creation
      - Updated the call site in `project_new` to pass `&env`
      b1db0269
    • nextjs-bot's avatar
      v16.2.0-canary.92 · 29812f26
      nextjs-bot authored
      29812f26
    • Will Binns-Smith's avatar
      Tracing: tag spans as failed if their runner fn fails (#91206) · f803fa7c
      Will Binns-Smith authored
      This adds a dedicated attribute, `failed`, to a span representing if the
      procedure failed. It's then set if the runner function threw.
      
      Test Plan: Added an e2e test
      f803fa7c
    • Tim Neutkens's avatar
      fix: correct appPaths sort order for parallel routes with route groups (#91160) · 21b9f6ba
      Tim Neutkens authored
      ### What?
      
      Fixes webpack dev 404s when parallel routes have children nested inside
      a route group (e.g. `@slot` + `(b1)/page`) and when a parallel route has
      `page.tsx` directly inside it (e.g. `@slot/page.tsx`).
      
      ### Why?
      
      Two separate issues caused 404s for parallel routes with route groups:
      
      1. **Sort order**: The three `appPaths` sort sites used bare `.sort()`
      (lexicographic ordering). `renderPageComponent` relies on
      `appPaths[appPaths.length - 1]` being the children/root page. Without
      route groups this works because `@` (0x40) sorts after lowercase letters
      — `/@slot/page` comes before `/page`. But when the children page is
      inside a route group, `(` (0x28) sorts before `@` (0x40), flipping the
      order: `/(b1)/page < /@slot/page`. Now the last item is the slot page
      instead of the children page, so the manifest lookup fails and a 404 is
      returned.
      
      2. **Double `__PAGE__` segment**: When a parallel route like `@slot` has
      `page.tsx` directly inside it, `resolveParallelSegments` returns
      `[PAGE_SEGMENT]` (an array) to signal that the loader should recurse
      into the slot directory to pick up layout/default files. However, the
      segment key normalization was mapping `PAGE_SEGMENT` to
      `PAGE_SEGMENT_KEY` (`__PAGE__`), while the recursion would also produce
      a `__PAGE__` for children — creating a double `__PAGE__` nesting (`slot:
      ['__PAGE__', { children: ['__PAGE__', ...] }, ...]`).
      
      ### How?
      
      **Sort order fix**: Adds a `compareAppPaths` comparator in
      `packages/next/src/shared/lib/router/utils/app-paths.ts` that sorts
      paths containing `/@` segments before paths without them, ensuring the
      children page is always last. Replaces the three bare `.sort()` calls
      with `.sort(compareAppPaths)` in:
      
      - `packages/next/src/build/entries.ts`
      - `packages/next/src/server/lib/router-utils/setup-dev-bundler.ts`
      -
      `packages/next/src/server/route-matcher-providers/dev/dev-app-page-route-matcher-provider.ts`
      
      **Loader tree fix**: Maps `PAGE_SEGMENT` to `'(slot)'` in the segment
      key normalization (same as `PARALLEL_VIRTUAL_SEGMENT`), instead of
      `PAGE_SEGMENT_KEY`. By the time this code is reached,
      `parallelSegmentKey === PAGE_SEGMENT` only occurs for the array case
      (the string case is handled by the early return), so this is safe. The
      actual `__PAGE__` is correctly created by the recursion.
      
      **Before:** `slot: ['__PAGE__', { children: ['__PAGE__', ...] }, ...]`
      **After:** `slot: ['(slot)', { children: ['__PAGE__', ...] }, ...]`
      
      Also adds an e2e test that verifies the fix across all modes (Turbopack
      dev, Turbopack start, webpack dev).
      21b9f6ba
    • Niklas Mischkulnig's avatar
      Lint against `.context(format!(...))` (#91122) · 19ff1bab
      Niklas Mischkulnig authored
      There are unfortunately a few false-positives, because this isn't aware of type information of course.
      19ff1bab
    • Luke Sandberg's avatar
      [Turbopack] Don't attempt to compress key blocks containing small keys (#90881) · c65b4347
      Luke Sandberg authored
      In turbo-persistence, if a key block has small keys don't attempt to compress the key block
      
      Currently all of our tables have small keys and none of them actually meet our compression threshold, thus all the time we spend attempting to compress them is just wasted CPU time.
      c65b4347
    • Tobias Koppers's avatar
      Add experimental.lightningCssFeatures config option (#90901) · 187f35f2
      Tobias Koppers authored
      ### What?
      
      Adds a new `experimental.lightningCssFeatures` config option that lets
      users control which CSS features lightningcss should always transpile
      (`include`) or never transpile (`exclude`), regardless of browserslist
      targets.
      
      ```js
      // next.config.js
      module.exports = {
        experimental: {
          useLightningcss: true,
          lightningCssFeatures: {
            include: ['light-dark', 'oklab-colors'],
            exclude: ['nesting'],
          },
        },
      }
      ```
      
      ### Why?
      
      Currently, lightningcss feature transpilation is determined solely by
      browserslist targets. There's no way to force transpilation of a
      specific feature (e.g., `light-dark()`) when targeting modern browsers
      that already support it, or to skip transpilation of a feature that the
      user wants to preserve as-is.
      
      This is useful for:
      - Forcing polyfill-style transpilation for features with incomplete
      browser support
      - Testing transpiled output for specific features
      - Opting out of specific transforms that may interfere with CSS tooling
      downstream
      
      ### How?
      
      **TypeScript config & validation:**
      - `config-shared.ts`: `LIGHTNINGCSS_FEATURE_NAMES` const array (single
      source of truth) with `LightningCssFeature` type derived from it, and
      `LightningCssFeatures` interface
      - `config-schema.ts`: Zod validation using
      `z.enum(LIGHTNINGCSS_FEATURE_NAMES)` for both include/exclude arrays
      
      **Feature name → bitmask mapping (Rust, shared via NAPI):**
      - `crates/next-core/src/next_config.rs`:
      `lightningcss_feature_names_to_mask()` maps feature name strings to
      `lightningcss::targets::Features` bitflag constants and returns a
      `Result<u32>` bitmask. Unknown feature names produce an error via
      `bail!`.
      - Exposed to JS via NAPI as `lightningcssFeatureNamesToMaskNapi`,
      callable through `bindings.css.lightning.featureNamesToMask(names)`
      - Single source of truth for feature name resolution — both webpack and
      Turbopack paths use this Rust function
      
      **Webpack path:**
      - `global.ts` / `modules.ts` pass config through to loader options
      - `loader.ts` calls `featureNamesToMask()` via the native bindings to
      compute include/exclude masks, then passes them to the SWC `transform()`
      call
      - The `lightningCssFeatures` without `useLightningcss` warning only
      shows when using webpack (Turbopack always uses lightningcss)
      
      **Turbopack path (Rust):**
      - `next_config.rs`: `LightningCssFeatures` struct for deserialization,
      accessor methods converting names → u32 bitmask via
      `lightningcss_feature_names_to_mask()`
      - Config flows through `CssOptionsContext` → `ModuleType::Css` →
      `CssModuleAsset` (using `LightningCssFeatureFlags { include, exclude }`
      struct) → `process.rs` where bitmasks are merged into
      `lightningcss::targets::Targets { include, exclude }`
      - Uses `u32` bitmask representation throughout to avoid adding
      lightningcss dependency to non-CSS crates
      
      **Defaults preserved:** `Nesting | MediaRangeSyntax` for Turbopack,
      `Nesting` for Webpack. User `include` is OR-ed on top, user `exclude`
      masks bits off.
      
      **Feature names:** 21 individual features (bit 0–20) + 3 composite
      groups (`selectors`, `media-queries`, `colors`), all in dash-case.
      
      ### Test
      
      - **Include test**
      (`test/e2e/app-dir/experimental-lightningcss-features/`) — targets
      Chrome 123 (which natively supports `light-dark()`) with `include:
      ['light-dark']`, then asserts the CSS output contains lightningcss
      transpilation markers (`--lightningcss-light`, `--lightningcss-dark`)
      instead of raw `light-dark()`.
      - **Exclude test**
      (`test/e2e/app-dir/experimental-lightningcss-features-exclude/`) —
      targets Chrome 100 (which does NOT support `light-dark()` natively) with
      `exclude: ['light-dark']`, then asserts the CSS output preserves raw
      `light-dark()` calls and does not contain transpilation markers.
      187f35f2
    • Luke Sandberg's avatar
      [turbopack] Render code frames on the turbopack side (#90534) · ff36c17c
      Luke Sandberg authored
      Not that error rendering performance is critical, but it is silly to pass frame information from turbopack to js just to have js pass the same information back to native code to draw a frame.
      ff36c17c
    • JJ Kasper's avatar
    • Benjamin Woodruff's avatar
      docs(turbopack): Merge old turbo-tasks concept mdbook page with crate's top-level rustdoc (#91120) · a18ae7d7
      Benjamin Woodruff authored
      Merges the content from https://turbopack-rust-docs.vercel.sh/turbo-engine/concepts.html with the crate-level documentation we already had, and adds some some graphics from https://nextjs.org/blog/turbopack-incremental-computation (currently linking to the vercel blob bucket).
      
      ### Rendered
      
      ![Screenshot 2026-03-09 at 14-35-56 turbo_tasks - Rust.png](https://app.graphite.com/user-attachments/assets/2233e4d1-c249-4be2-af02-d15bd4b9a0cf.png)
      a18ae7d7
    • Luke Sandberg's avatar
      [turbopack] Move empty snapshot filtering into take_snapshot (#90166) · a5f36eb2
      Luke Sandberg authored
      When snapshotting we create a number of iterators to encode every `shard` of the `modified` dashmap.
      
      Some of these shards end up being empty and rarely they might all be empty.   To avoid the overhead of opening a write transaction we detect this prior to persisting.  Unfortunately this is done in a single threaded pass and can be expensive since there are often thousands of shards.
      
      To improve this we move the filtering into shard production so it can happen concurrently.
      
      This is a small improvment, from vercel-site builds timing the `Finished writing to filesystem cache` event we get
      
      Before: 6.6s 7.8s 7.1s
      After: 6.6s 6.5s 6.4s
      
      So a small progression
      a5f36eb2
    • Luke Sandberg's avatar
      [turbopack] hashing improvements to turbo-persistence (#90936) · 7640d0bd
      Luke Sandberg authored
      ## Summary
      
      Reduces CPU overhead in turbo-persistence SST reads through three optimizations:
      
      1. **Switch from `twox-hash` to `xxhash-rust`** — `twox_hash::XxHash3_64::with_seed(0)` heap-allocates a 192-byte secret buffer on every call. `xxhash_rust::xxh3::Xxh3Default::new()` is a `const fn` with zero allocation. Applied to both `turbo-persistence` and `turbo-tasks-hash`.
      
      2. **Bulk `write()` in `KeyBase::hash` impls** — The hash implementations were feeding bytes one at a time via `write_u8()`, preventing xxh3 from using its optimized bulk ingestion path. Changed all slice-backed types (`&[u8]`, `[u8; N]`, `Vec<u8>`, `Box<[u8]>`) to use a single `state.write(slice)` call.
      
      3. **Binary search improvements in SST lookups:**
         - **Index block lookup**: Replaced hand-rolled binary search with `as_chunks::<10>()` + stdlib `binary_search_by`, making the code simpler and leveraging the stdlib's optimized search.
         - **Duplicate key scans**: When collecting all entries with the same key (FIND_ALL mode), the backward/forward scans now use the binary search bounds (`l..m` and `m+1..r`) instead of scanning from `0` to `entry_count`. The binary search already proved entries outside these bounds are different, so this avoids unnecessary comparisons.
         - **`entry_matches_key` helper**: Equality checks during duplicate scans now use a dedicated function that avoids recomputing the full hash when no hash is stored in the block (block type 2/4). Previously `compare_hash_key` would call `hash_key()` to compute the full hash even when only an equality check was needed.
      
      ## Benchmark results
      
      Compared against the `fixed_size_blocks` branch using `cargo bench -p turbo-persistence -- 'read/get/key_8'` (8-byte keys, 4-byte values):
      
      | Benchmark | Change |
      |-----------|--------|
      | 10.67Mi/compacted/miss/cached | **-45%** |
      | 10.67Mi/compacted/hit/cached | **-35%** |
      | 10.67Mi/uncompacted/hit/cached | **-35%** |
      | 10.67Mi/uncompacted/hit/uncached | **-22%** |
      | 10.67Mi/uncompacted/miss/uncached | **-22%** |
      | 10.67Mi/uncompacted/miss/cached | **-21%** |
      | 10.67Mi/20commits/hit/cached | **-26%** |
      | 10.67Mi/20commits/miss/* | -13% |
      | 85.33Mi/compacted/hit/uncached | **-56%** |
      | 85.33Mi/compacted/hit/cached | **-22%** |
      | 85.33Mi/compacted/miss/* | **-22%** |
      | 85.33Mi/uncompacted/hit/cached | -10% |
      | 85.33Mi/20commits/hit/uncached | -12% |
      | 85.33Mi/20commits/hit/cached | -6% |
      | 85.33Mi/20commits/miss/* | -1 to -3% |
      
      Largest wins on cached paths with smaller datasets where CPU cost (hashing, search) dominates over I/O.
      7640d0bd