1. 02 Mar, 2026 10 commits
  2. 01 Mar, 2026 7 commits
    • nextjs-bot's avatar
      v16.2.0-canary.70 · 5e3af2ce
      nextjs-bot authored
      5e3af2ce
    • Andrew Clark's avatar
      instant(): fix cookie handling for fresh page loads (#90613) · a362fd27
      Andrew Clark authored
      Previously, instant() used page.evaluate() to set the cookie via
      document.cookie, which required a page to already be loaded. This meant
      the cookie wasn't present on the very first navigation.
      
      Switch to Playwright's browser context cookie API so the cookie is set
      before any page loads. If the page is already loaded, the base URL is
      inferred automatically. Otherwise, a new baseURL option allows setting
      the cookie before the first navigation.
      a362fd27
    • Andrew Clark's avatar
      experimental.prefetchInlining: bundle segment prefetches into a single response (#90555) · 9ce8d136
      Andrew Clark authored
      ## Background
      
      Next.js 16 introduced per-segment prefetching through the Client Segment
      Cache. Rather than fetching all data for a route in a single request,
      the client issues individual requests for each segment in the route
      tree. This design improves cache efficiency: shared layouts between
      sibling routes (e.g., /dashboard/settings and /dashboard/profile sharing
      a /dashboard layout) are fetched once and reused from the client cache,
      avoiding redundant data transfer.
      
      The trade-off is request volume. A route with N segments now produces N
      prefetch requests instead of one. Users upgrading from older versions
      notice significantly more network activity in their devtools, even
      though the total bytes transferred may be similar or lower due to
      deduplication.
      
      Per-segment fetching is still a reasonable default for many sites. These
      prefetch requests are served from cache, they're fast, and they run in
      parallel. The main scenario where the trade-off breaks down is
      deployment environments that charge per-request. But even setting aside
      cost, there is a theoretical performance threshold where very small
      segments are better off inlined — the per-request overhead (connection
      setup, headers, scheduling) exceeds the cost of transferring duplicate
      bytes. This is analogous to JS bundlers, which inline small modules
      rather than creating separate chunks, because the overhead of an
      additional script tag or dynamic import outweighs the bytes saved.
      
      ## What this change does
      
      This adds `experimental.prefetchInlining`, a boolean option in
      next.config.js. When enabled, the server bundles all segment data for a
      route into a single `/_inlined` response rather than serving each
      segment individually. The tree prefetch (`/_tree`), which provides route
      structure metadata, remains a separate request — but optimistic routing
      (#88965) eliminates that request entirely by predicting the route
      structure client-side. With both features enabled, prefetching is
      effectively one request per link.
      
      The fundamental trade-off is straightforward: inlining reduces request
      count at the cost of deduplication. Each inlined response includes its
      own copy of any shared layout data, so two sibling routes will each
      transfer the shared layout rather than sharing a single cached copy.
      This is the same trade-off that compilers and bundlers face when
      deciding whether to inline a function: inlining eliminates the overhead
      of indirection (here, extra HTTP requests) but increases total size when
      the same data appears in multiple call sites.
      
      ## Future direction
      
      The boolean flag is a stepping stone. The observation that there is a
      natural size threshold below which inlining is strictly better — where
      per-request overhead dominates the cost of any duplicate bytes — points
      toward a size-based heuristic, analogous to how compilers choose an
      inlining threshold. Small segments would be inlined automatically;
      segments exceeding a byte threshold would be "outlined" into separate
      requests where deduplication can take effect. For most applications,
      this would require no configuration. For applications with specific
      latency or bandwidth constraints, an option to adjust the threshold
      would let developers tune their position on the requests-vs-bytes curve.
      Adaptive heuristics based on network conditions are also possible,
      though further out.
      9ce8d136
    • Michal Piechowiak's avatar
      feat: provide nextVersion to modifyConfig adapter hook (#90735) · 4d2ac245
      Michal Piechowiak authored
      For providers that either don't manage or allow for custom build
      commands, checking Next.js version in their builders is not reliable.
      Especially for providers that already have existing support there needs
      to be very reliable way to only apply certain configuration adjustments
      for supported versions of Adapters API.
      
      So this adds `nextVersion` to `modifyConfig` to allow that. It also
      brings parity to this hook (`onBuildComplete` already does receive
      `nextVersion`.
      
      Corresponding adjustments for docs (just types update) prepared in
      https://github.com/vercel/next.js/compare/canary...pieh:next.js:docs/nextVersion-in-adapter-modifyConfig
      
      <!-- 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 #
      
      -->
      4d2ac245
    • Sebastian "Sebbie" Silbermann's avatar
    • Jiwon Choi's avatar
      Use commit-based tarball URL in PR stats comment (#90709) · 4e6beadc
      Jiwon Choi authored
      The previous method of using the PR endpoint under the hood calls the
      GitHub API to get the commit SHA, which is a waste of resources, so just
      use the commit SHA directly in the tarball URL.
      4e6beadc
    • Sebastian "Sebbie" Silbermann's avatar
  3. 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
  4. 27 Feb, 2026 14 commits