1. 28 Feb, 2026 9 commits
    • nextjs-bot's avatar
      v16.2.0-canary.69 · fb694e9d
      nextjs-bot authored
      fb694e9d
    • JJ Kasper's avatar
      Add custom cleanup script support for deploy tests (#90696) · f18e6885
      JJ Kasper authored
      ## Summary
      - Adds `cleanupScriptPath` workflow dispatch input and
      `NEXT_TEST_CLEANUP_SCRIPT_PATH` env var to `test_e2e_deploy_release.yml`
      (webpack + turbopack jobs)
      - Adds `cleanupUsingCustomScript()` method to `NextDeployInstance`
      following the same pattern as the existing deploy and logs scripts
      - Calls the cleanup script in `destroy()` before existing teardown logic
      
      ---------
      Co-authored-by: 's avatarVercel <vercel[bot]@users.noreply.github.com>
      f18e6885
    • Benjamin Woodruff's avatar
      c2a27526
    • Benjamin Woodruff's avatar
      Turbopack: Allow turbopack-node backend to be swapped at runtime using an… · c5b2cf1e
      Benjamin Woodruff authored
      Turbopack: Allow turbopack-node backend to be swapped at runtime using an experimental config option (#90671)
      
      <!-- 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?
      
      ### Why?
      
      ### How?
      
      Closes NEXT-
      Fixes #
      
      -->
      
      Follow-up to https://github.com/vercel/next.js/pull/86266  
      This was mostly LLM-generated, but it's just moving things around and threading through a config option.  
        
      We'd like to be able to turn this on/off with an experimental config option:  
      \- Fixes issues where RA thinks a bunch of code is dead.  
      \- Lets us isolate potential issues to the worker thread implementation.  
      \- Provides an escape hatch for users in case there are issues.  
      \- Better fits the cargo "additive feature" model.
      c5b2cf1e
    • Luke Sandberg's avatar
      turbo-persistence: streaming SST writer for reduced memory usage (#90617) · 28df39ba
      Luke Sandberg authored
      ### What?
      
      Replace the two-pass SST file write approach with a single-pass `StreamingSstWriter` that writes blocks incrementally as entries arrive. Also replace the compaction `Collector`'s double-buffered `last_entries` pattern with a streaming collector that wraps the new writer.
      
      ### Why?
      
      The previous SST write path materialized all entries in memory (keys + values), then wrote all value blocks, then all key blocks. During compaction, the `Collector` maintained two full entry vectors (`entries` + `last_entries`) for size balancing. For large SST files (256MB+), this required holding hundreds of MB of entry data in memory simultaneously.
      
      The streaming approach reduces peak memory per writer from hundreds of MB to ~200KB by writing blocks to disk as soon as possible rather than buffering everything.
      
      ### How?
      
      **Phase 1: `StreamingSstWriter` in `static_sorted_file_builder.rs`**
      
      The key insight is that the SST reader is **block-index-addressed** — it locates blocks by index via the offset table, not by file position. So interleaving value blocks and key blocks in any order is fully compatible with the reader.
      
      The writer processes entries one at a time:
      - **Medium values** are written to disk immediately as individual blocks
      - **Small values** accumulate in a buffer and flush when reaching 8KB
      - **Key blocks** flush incrementally as the resolved boundary advances
      
      A `VecDeque<PendingKeyEntry>` holds entries waiting for their value blocks to be written. Each pending entry contains a `ValueRef` that tracks where its value lives:
      - `Small { block_index, offset, size }` — already resolved
      - `PendingSmall { small_block_id, offset, size }` — waiting for small block flush
      - `Medium { block_index }` — already resolved (written immediately)
      - `Inline`, `Blob`, `Deleted` — no value block needed
      
      The `first_pending_small_index` partitions `pending_keys` into resolved entries (front) and unresolved entries (back). Key blocks are flushed **incrementally** via `try_flush_key_blocks()` at the two points where this boundary advances:
      - When a small value block is flushed — resolves all `PendingSmall` entries, then calls `try_flush_key_blocks()` to flush any complete key blocks from the resolved region
      - In `advance_boundary_to()` — processes resolved entries and flushes key blocks via `try_flush_key_block()` when they exceed size or entry count limits
      
      This makes adding N entries **O(N) total** instead of O(N²) from the earlier per-call scan approach.
      
      **Key block flushing**: The `try_flush_key_block()` method combines the check-and-flush logic — it tests whether adding the next entry would exceed `MAX_KEY_BLOCK_SIZE` (16KB) or `MAX_KEY_BLOCK_ENTRIES`, and if so, flushes the accumulated key block. Entries sharing the same key hash are never split across blocks.
      
      **AMQF filter**: Created with `max_entry_count` (an upper bound), then shrunk via `shrink_to_fit()` on `close()` to reclaim unused capacity while preserving false positive rates.
      
      **Index block writing**: `IndexBlockBuilder` is generic over `Write` and writes directly to the `BufWriter` during `close()`, avoiding an intermediate buffer allocation. Index blocks use `write_raw_block_to_file` since they are never compressed.
      
      **File size**: Computed from the last block offset plus the offset table size, avoiding a `stream_position()` call (which would trigger an unnecessary flush + seek syscall).
      
      `write_static_stored_file()` is reimplemented as a thin wrapper around `StreamingSstWriter`, so existing callers (`write_batch.rs`, benchmarks) need zero changes.
      
      **Phase 2: Streaming compaction in `db.rs`**
      
      The compaction `Collector` is simplified to wrap an `Option<(u32, StreamingSstWriter)>`. The old pattern of maintaining `entries` + `last_entries` vectors with swap/early-flush/split logic (~100 lines) is replaced by direct calls to `writer.add()`. The collector tracks total key/value sizes and a `ValueBlockCountTracker` to know when to finish the current writer and start a new one.
      
      **Memory savings:**
      
      | | Previous (compaction) | Streaming |
      |---|---|---|
      | Entry storage | `entries` + `last_entries` (up to 2× full entry vecs) | ~800 pending key entries (~80KB) |
      | Value data | All values held in memory until written | Written immediately (medium) or after 8KB (small) |
      | Peak for 256MB SST | Hundreds of MB | ~200KB per writer |
      
      **Performance**
      Both compaction and write benchmarks are within the noise.  It makes sense that this might be slightly slower due to some additional per-entry work, but writing is dominated by other factors `write` syscalls, compression and memcopies into temporary buffers. 
      
      **Files changed:**
      - `turbopack/crates/turbo-persistence/src/static_sorted_file_builder.rs` — `StreamingSstWriter` with incremental key block flushing via `try_flush_key_block()`, `PendingKeyEntry`, `ValueRef`; generic `IndexBlockBuilder<W: Write>`; `write_static_stored_file` as wrapper; AMQF `shrink_to_fit()` on close
      - `turbopack/crates/turbo-persistence/src/db.rs` — Replaced compaction `Collector` with streaming version
      - `turbopack/crates/turbo-persistence/src/lib.rs` — Export `StreamingSstWriter`
      - `turbopack/crates/turbo-persistence/src/value_block_count_tracker.rs` — Removed dead `is_half_full()`/`reset_to()` methods
      
      **Verification:**
      - `cargo clippy -p turbo-persistence` — zero warnings
      - `cargo test -p turbo-persistence` — all 46 tests pass
      - `cargo fmt -p turbo-persistence -- --check` — clean
      - Criterion benchmarks show no performance regressions (write + compaction within noise)
      28df39ba
    • nextjs-bot's avatar
      v16.2.0-canary.68 · 2071a816
      nextjs-bot authored
      2071a816
    • Will Binns-Smith's avatar
      Turbopack: restrict server HMR to app pages (#90663) · a0a18a23
      Will Binns-Smith authored
      App router types like routes go through the traditional `require` route
      bypassing the Turbopack runtime, so they aren't easily solved with
      server HMR right now.
      
      Test Plan: Added an e2e test.
      
      ---------
      Co-authored-by: 's avatarvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
      a0a18a23
    • Niklas Mischkulnig's avatar
      tests: Fix immutableAssetToken extraction (#90668) · 96512309
      Niklas Mischkulnig authored
      Fixes this deploy test failure:
      https://github.com/vercel/next.js/actions/runs/22499483165/attempts/2
      
      The output might be:
      ```
      Building: └ ○ /nested
      Building: ○  (Static)   prerendered as static content
      Building: ƒ  (Dynamic)  server-rendered on demand
      Building: > @ post-build /vercel/path0
      Building: > node -e 'console.log("BUILD" + "_ID: " + fs.readFileSync(".next/BUILD_ID") + "\nDEPLOYMENT" + "_ID: " + process.env.NEXT_DEPLOYMENT_ID + "\nIMMUTABLE_ASSET" + "_TOKEN: " + process.env.VERCEL_IMMUTABLE_ASSET_TOKEN)'
      Building: BUILD_ID: build-TfctsWXpff2fKS
      Building: DEPLOYMENT_ID: dpl_5Qad8NbhCPWn7QRf5TiCePi58vVi
      Building: IMMUTABLE_ASSET_TOKEN: undefined
      Building: Build Completed in /vercel/output [15s]
      Building: Deploying outputs...
      Building: Deployment completed
      ```
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      96512309
    • JJ Kasper's avatar
      Centralize test timings to fix shard divergence in CI (#90672) · 683180bf
      JJ Kasper authored
      ## Summary
      
      For context we discovered jobs were not reliably always running in
      https://github.com/vercel/next.js/pull/90668 as addapters + turbopack
      group ran more tests than just turbopack group.
      
      - Each sharded test sub-job independently fetched test timings from KV
      via a turbo task. Because turbo cache keys can vary across job groups
      and KV can return slightly different data at different times, the
      sharding algorithm produced different test-to-shard assignments across
      groups — causing some tests to be missing entirely and others to run in
      multiple shards.
      
      - Adds a `--require-timings` flag to `run-tests.js` that fails loudly if
      `test-timings.json` can't be loaded from disk, preventing silent
      fallback to KV or round-robin.
      
      - Adds a `testTimingsArtifact` input to `build_reusable.yml` that
      downloads a pre-built timings artifact instead of fetching via turbo.
      When unset (default), existing behavior is preserved.
      
      - In both `test_e2e_deploy_release.yml` and `build_and_test.yml`,
      timings are now fetched once in a setup job, uploaded as a GitHub
      artifact, and downloaded by all sub-jobs — guaranteeing identical shard
      assignments across all job groups.
      
      ## Test plan
      
      - [ ] Verify `build_and_test.yml` jobs pick up the shared `test-timings`
      artifact
      - [ ] Verify `test_e2e_deploy_release.yml` deploy jobs pick up the
      shared `test-timings` artifact
      - [ ] Verify workflows that don't pass `testTimingsArtifact` (e.g.
      `integration_tests_reusable.yml`, `pull_request_stats.yml`) still use
      the turbo fallback path unchanged
      683180bf
  2. 27 Feb, 2026 22 commits
  3. 26 Feb, 2026 9 commits
    • nextjs-bot's avatar
      v16.2.0-canary.64 · 8f5afa35
      nextjs-bot authored
      8f5afa35
    • Will Binns-Smith's avatar
      Turbopack server hmr: Implement `restart` event (#90550) · dc3b6ede
      Will Binns-Smith authored
      This implements the `restart` event, fully evicting all caches. This is needed for when client manifest changes are made.
      
      Test Plan: CI for https://github.com/vercel/next.js/pull/90389
      dc3b6ede
    • Andrew Imm's avatar
      Pre-warm a single NodeJS instance when the next devserver starts (#90174) · ee885f86
      Andrew Imm authored
      When cold-booting `next dev` on a fresh create-next-app, on the first server hit we need to fetch fonts and compile CSS, which takes up nearly half of the request time.
      
      It shouldn't be necessary to wait until the first server request to launch the first NodeJS process (eventually used for PostCSS processing in Tailwind). Once the server has started, we can anticipate that first request and pre-warm a single Node process.
      
      Because we grab the boot semaphore, if a request comes in as soon as the server is ready, it waits on the semaphore to resolve, and at most it takes as long as it would before this change. In all likelihood, the Node process is ready before any server request comes in.
      
      It also slightly saves time on `next build`
      
      I'd appreciate scrutiny of all the ways this can go wrong.
      ee885f86
    • JJ Kasper's avatar
      Fix edge index page _next/data route (#90611) · 0db78041
      JJ Kasper authored
      Fixes failing assertion with turbopack
      
      Verified against turbopack + adapter deploy test locally
      <img width="2076" height="1336" alt="CleanShot 2026-02-26 at 13 25
      30@2x"
      src="https://github.com/user-attachments/assets/a8c66314-8163-4371-b02a-dc7146989425"
      />
      
      
      x-ref:
      https://github.com/vercel/next.js/pull/90600#issuecomment-3968044160
      0db78041
    • nextjs-bot's avatar
      v16.2.0-canary.63 · b6d47641
      nextjs-bot authored
      b6d47641
    • Luke Sandberg's avatar
      turbo-persistence: drop key compression dictionary from SST files (#90608) · d52877ef
      Luke Sandberg authored
      ## Summary
      
      - Remove the zstd key compression dictionary from SST files, simplifying
      the on-disk format
      - Key blocks now use plain LZ4 compression (same as value blocks),
      eliminating the zstd dependency
      - Update the turbo-persistence README to reflect the format changes
      
      ## Why
      
      The key compression dictionary added complexity (zstd dependency,
      dictionary computation, dual decompression paths) with diminishing
      returns. Plain LZ4 is already used for value blocks and provides
      sufficient compression for key blocks. This simplifies both the SST file
      format and the compaction/inspection tooling.
      
      This main goal is to unblock streaming SST writes.
      
      ## What Changed
      
      **On-disk format (breaking):**
      - SST files no longer start with a serialized key compression dictionary
      - Meta file entries no longer include the
      `key_compression_dictionary_length` field
      
      **Code:**
      - Removed `zstd` dependency from `turbo-persistence`
      - Removed dictionary computation in `StaticSortedFileBuilder`
      - Simplified `sst_inspect` tool (no more dictionary-aware decompression)
      - Removed `key_compression_dictionary_length` from
      `StaticSortedFileMetaData`, `MetaEntry`, and `MetaFileBuilder`
      
      **Docs:**
      - Updated README meta file format (removed dictionary length field)
      - Updated README SST file format (removed dictionary region)
      - Updated compression description to reference LZ4 directly
      
      ## Test Plan
      
      - Existing turbo-persistence tests and benchmarks pass with the format
      changes
      - `sst_inspect` tool updated to work without dictionary logic
      
      ---------
      Co-authored-by: 's avatarTobias Koppers <tobias.koppers@googlemail.com>
      d52877ef
    • Jiwon Choi's avatar
      Add `unstable_retry()` to error.js (#89685) · 9d13b676
      Jiwon Choi authored
      Extends the error components API to give better control over recovery.
      Previously, the `reset()` prop only cleared the error state and
      re-rendered the children. However, this only handles a temporary
      rendering error.
      
      The error can be due to data fetching or an RSC phase. In these cases,
      `reset()` alone is not sufficient. Users would even need to implement
      retry logic using `router.refresh()`.
      
      Therefore, this PR adds a new `unstable_retry()` prop that calls
      `router.refresh()` and `reset()` within a `startTransition()` to provide
      built-in retry logic. This feature is expected to be preferred over the
      `reset()` prop. Only the cases where you'd choose `reset()` are when you
      have a reason to do a sync reset without loading any new data.
      
      Closes NAR-767
      9d13b676
    • Hendrik Liebau's avatar
      Fix per-segment prefetching for initial loads with Cache Components (#90610) · 2ba73b7a
      Hendrik Liebau authored
      The `S` field in the RSC payload was only set to `true` during static
      generation, but the client used it to determine whether a route supports
      per-segment prefetching (`isPPREnabled` on the route cache entry). For
      partially static pages with Cache Components enabled, the initial HTML
      is served via PPR resume, which generates the RSC payload at request
      time with `isStaticGeneration` set to `false`. This caused `S` to be
      `false` even though the route fully supports per-segment prefetching.
      
      This caused the prefetch scheduler to fall back to the `LoadingBoundary`
      fetch strategy instead of `PPR`, which skipped fetching
      `_head.segment.rsc` and instead sent a `metadata-only` dynamic request.
      That request returned a 404 locally (harmless) but a 200 with an empty
      body on Vercel, which interfered with same-page navigation refreshes
      introduced in #76223 and exposed by the route cache keying fix in
      #90400.
      
      To fix this, `S` is now also set to `true` when `cacheComponents` is
      enabled, since all Cache Components routes support per-segment
      prefetching. When Cache Components is disabled, `S` continues to rely
      solely on `isStaticGeneration`, which is correct because fully static
      pages always have both their RSC payload and per-segment prefetch
      responses generated at build time.
      
      This PR also renames `isPPREnabled` to `supportsPerSegmentPrefetching`
      on the client and updates the `S` field comments in the RSC payload
      types to better reflect the field's actual meaning.
      2ba73b7a
    • Jiwon Choi's avatar
      Allow `reset()` from user's global-error (#89684) · 10725f84
      Jiwon Choi authored
      User's `global-error.js` is within the router. There's no reason it
      shouldn't have access to the options available to the `error.js`
      component. It was already available on prod. This PR syncs dev behavior
      to prod.
      
      For the follow-up feature, `retry()` will also be available in
      `global-error.js`.
      
      ---------
      Co-authored-by: 's avatarvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
      10725f84