- 04 Mar, 2026 29 commits
-
-
nextjs-bot authored
-
Tobias Koppers authored
## Summary Follow-up to #90514 addressing review feedback from @lukesandberg: - **Extract webpack layer helpers to `webpack-layer.ts`**: Moves `shouldUseReactServerCondition` and `isWebpackAppPagesLayer` out of the large `utils.ts` into their own module, reducing transitive dependencies pulled into `swc/options.ts` (reverts the revert from the previous PR) - **Restore top-level import of `throwTurbopackInternalError`**: The lazy `require()` in `swc/index.ts` was unnecessary since `createProject` is always called — restores the simpler top-level import - **Remove dead `getSupportedBrowsers` re-export from `utils.ts`**: All importers already import directly from `get-supported-browsers.ts`, so the re-export was unused - **Extract `formatIssue` and `isRelevantWarning` to `format-issue.ts`**: Moves these functions (and their private helpers) out of the large `turbopack/utils.ts` into a dedicated module, so `print-build-errors.ts` doesn't pull in all of `turbopack/utils` ## Test plan - `pnpm --filter=next types` passes - Unit tests for `formatIssue` pass (`utils.test.ts` updated to import from new module) - NFT test expectations updated for the changed module graph
-
nextjs-bot authored
-
Zack Tanner authored
Plumbs the new `partialFallback` through `onBuildComplete`, which is consumed by `adapter-vercel` to signal that a prerender is a partial fallback (PR forthcoming, once this lands, so it's available on the types). For more information on what a partial fallback is, see the downstack PR.
-
Zack Tanner authored
This seems to be failing for our deploy test workflow ([x-ref](https://github.com/vercel/next.js/actions/runs/22685809647/job/65778800145)). Updating to `continue-on-error` similar to https://github.com/vercel/next.js/pull/89098 because this check doesn't seem reliable. If it fixes, will just remove in both spots all together.
-
nextjs-bot authored
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack.
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Jiwon Choi authored
Stacked on https://github.com/vercel/next.js/pull/90721 Verified deployment tests pass on CI: https://github.com/vercel/next.js/actions/runs/22541051404
-
Aurora Scharff authored
### What? Add `aurorascharff` to the devex team labeler configuration. ### Why? New team member onboarding. ### How? Added username to the relevant pattern entries in the labeler config. --------- Co-authored-by:vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
-
Hendrik Liebau authored
When navigating to a page with `unstable_instant: { prefetch: 'runtime' }` and no prior prefetch (e.g. `prefetch={false}` or clicking before prefetch completes), the server now embeds a runtime prefetch stream in the dynamic RSC navigation payload. On the client, this stream is decoded and written into the segment cache so that subsequent navigations to the same page can serve runtime-prefetchable content (cookies, headers, searchParams) instantly, without needing a separate prefetch request. On the server, `generateStagedDynamicFlightRenderResult` detects routes with runtime prefetching enabled and attaches a `CacheSignal` and `PrerenderResumeDataCache` to the `RequestStore`. The dynamic render fills these caches as a side effect. Once `cacheSignal.cacheReady()` resolves, a final runtime prerender (the same 5-stage pipeline used for regular runtime prefetches) runs and its output is piped into a `TransformStream` whose readable side is included in the RSC payload as the `p` field on the `NavigationFlightResponse`. This avoids a separate prospective prerender because the dynamic render has already warmed the caches. On the client, `processRuntimePrefetchStream` strips the isPartial byte, decodes the inner Flight stream, and the result is written into the segment cache via `writeDynamicRenderResponseIntoCache` with `FetchStrategy.PPRRuntime`. Both the `navigateToUnknownRoute` and `fetchMissingDynamicData` code paths handle the new stream. This is gated on the explicit `unstable_instant` opt-in because it adds extra server processing (a full runtime prerender per navigation request) and increases payload size. It also requires that the runtime prefetch output has been validated first. Known limitation: the runtime prefetch cache write currently evicts the static cache entry (which may have a longer stale time) because `upsertSegmentEntry` treats the fallback match as a replacement target. This means that after the runtime cache expires, the static cache is no longer available as a fallback. A follow-up may address this with a layered cache approach where entries with different fetch strategies and stale times coexist independently. Extracting runtime data from initial HTML loads (the PPR resume path) is also deferred to a follow-up. -
Niklas Mischkulnig authored
Unify the list of Node/Edge iexternals. Turns out `readline/promises` and `stream/consumers` was missing in some places. Closes https://github.com/vercel/next.js/issues/90765
-
Niklas Mischkulnig authored
A regression from https://github.com/vercel/next.js/issues/86576 Closes https://github.com/vercel/next.js/issues/87898 Closes PACK-6421
-
Jiwon Choi authored
Stacked on https://github.com/vercel/next.js/pull/90726 Migrate legacy PPR tests to Cache Components
-
Jiwon Choi authored
Stacked on https://github.com/vercel/next.js/pull/90713 This PR removes `prerender-ppr` case handling in the codebase. Verified deployment tests pass on CI: https://github.com/vercel/next.js/actions/runs/22539297668
-
Hendrik Liebau authored
When a partially static page is loaded via initial HTML (PPR resume), the RSC payload now includes the `l` (static stage byte length) field, enabling the client router to extract and cache the static stage during hydration. Subsequent navigations to the same page serve the cached static content instantly while streaming in dynamic content. On the server, the resume path in `renderToStream` now uses staged rendering (mirroring `generateStagedDynamicFlightRenderResult`) when Cache Components is enabled. A `StagedRenderingController` separates the static and dynamic stages, and `countStaticStageBytes` resolves the byte length promise that Flight serializes into the stream as `l`. `getRSCPayload` accepts `staleTimeIterable` and `staticStageByteLengthPromise` options to wire `s` and `l` into the `InitialRSCPayload`. On the client, `app-index.tsx` tees the inlined Flight stream when Cache Components is enabled. One copy goes to React for decoding, the other is passed to `createInitialRouterState`. When `l` is present (partially static), the clone is truncated at the byte boundary via `decodeStaticStage` and written into the segment cache via `writeStaticStageResponseIntoCache` with `isResponsePartial: true`. When `l` is absent but `s` is present (fully static), the same function is used with `isResponsePartial: false`. `createInitialRouterState` now accepts a single `initialRSCPayload: InitialRSCPayload` prop instead of individual destructured fields.
-
Sebastian "Sebbie" Silbermann authored
Co-authored-by:
Cursor Agent <cursoragent@cursor.com> Co-authored-by:
Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Co-authored-by:
vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
-
Matt Mastracci authored
# What Add an ast-grep rule to use `bail!` rather than `Err(anyhow!(` in a return position. # Why This is slightly more compact, and allows us to port more code over to turbofmt/turbobail. Note: _this PR was previously merged into another branch due to a GH bug_
-
Jiwon Choi authored
Stacked on https://github.com/vercel/next.js/pull/90704 This PR replaces `experimental.isRoutePPREnabled` render options with `cacheComponents` and removes unused code. Verified deployment tests pass on CI: https://github.com/vercel/next.js/actions/runs/22536405880
-
Hendrik Liebau authored
When a fully static page is loaded (via initial HTML or client-side navigation), the segments are now written into the segment cache so subsequent navigations can be served entirely from cache without server requests. Initial HTML: The RSC payload inlined in the HTML is written during hydration via `getStaleAt` + `writeStaticStageResponseIntoCache` with `isResponsePartial: false`, using `FetchStrategy.Full` since all segments are present. A `StaleTimeIterable` (`s` field) is included in the `InitialRSCPayload` during the Cache Components prerender path to provide the stale time. Navigation: The `isResponsePartial` flag from the prepended byte (stripped by `processFetch`) is now also used to determine how segments from `writeStaticStageResponseIntoCache` are cached. For fully static routes (`isResponsePartial: false`), segments are written as non-partial so no dynamic follow-up is needed. The route tree used for cache writes is now always derived from the Flight data itself (via `convertServerPatchToFullTree`), rather than from a pre-existing route cache entry. This guarantees the tree stays in sync with the response and avoids key mismatches between the static stage tree and the per-segment prefetch tree for parallel route slots. When writing the head into the cache, `isHeadPartial` from the server is overridden to `false` for non-partial responses, but only when Cache Components is enabled. This corrects the server's conservative `isPossiblyPartialHead` marking during static generation. Without Cache Components, the server already sends the correct value. Responses without a recognized marker byte (e.g. regular navigations that don't go through the prerender path) are conservatively treated as partial. Partially static pages (where the static stage needs to be extracted via byte-level truncation of the initial HTML Flight stream) will be handled in a follow-up. --------- Co-authored-by:Andrew Clark <git@andrewclark.io>
-
Matt Mastracci authored
# What Add turbofmt! and turbobail! proc macros for async string formatting with Vc<T> and ResolvedVc<T> values. A new, agent-friendly `FORMATTING.md` file is added to help agents figure out how these macros work. # Why Formatting strings that include turbo-tasks values currently requires manually .await?ing each Vc, then calling format!, then converting to RcStr via .into(). By using macros, we can reduce a lot of boilerplate and potentially offer some opportunities for optimizations by reducing intermediate, throwaway tasks. # How We make use of the "auto-deref" pattern in Rust to choose the "best" formatting option: ValueToString or Display. - Zero-alloc FormatIter: A shared iterator parser over format strings (RawString, EscapedBrace, VarRef, VarRefFormat) that both macros and the derive use, replacing duplicated manual parsing. - Borrow-based capture: turbofmt! uses async { .. } (not async move), so non-Copy types like FileSystemPath can be used in multiple turbofmt! calls without cloning. - Debug on StringifyType: Enables {:?} format specs in turbofmt!. - Converted ~30 call sites across next-core, turbo-tasks-fs, turbopack-core, turbopack-ecmascript, and others. # What's Left - Constants cannot be formatted with turbofmt! yet because of arcane Rust hygiene rules (similar issue to https://github.com/rust-lang/rust/issues/131446) - rust-analyzer doesn't show these format strings as "real" format strings yet because of limitations of the analyzer, but this should be possible to make work. - Automatic derive for ValueToStringRef to avoid intermediate tasks in a few places where formatting is trivial - turbowrite!/turbowriteln! could clean up a bit more code -
Jiwon Choi authored
This PR replaces the legacy PPR configs in the codebase with the `cacheComponents` config. Confirmed deployment test passes https://github.com/vercel/next.js/actions/runs/22533307017 --------- Co-authored-by:
Hendrik Liebau <mail@hendrik-liebau.de>
-
Matt Mastracci authored
# What Make turbotask function registration const -- all function registration blocks are true &'static items, compiled directly into the binary. Removes a few thousand allocations of type names and boxed impls of TaskFn. # Why We have approx 2k functions, so the cost of Lazy construction + temporary allocations adds up (even with compiler optimization). This also unlocks the opportunity for further startup optimizations (in later PRs). # How The `#[turbo_tasks::function]` macro now generates static items initialized directly with const fn constructors instead of `Lazy::new(|| ...)`, using `const { &into_task_fn(f) as &dyn TaskFn }` blocks to produce `&'static dyn TaskFn` trait objects at compile time from zero-sized function items. Global names that previously required runtime format!() + Box::leak() are now computed at compile time via `const_type_name()` (a const wrapper around `std::any::type_name`) and a `const_concat!` macro that concatenates string slices into a fixed-size byte array. The NativeFunction struct, ArgMeta, and the into_task_fn/into_task_fn_with_this wrappers are all const fn-constructible, with input types inferred through a TaskFnInputs trait that maps wrapper types to their argument tuples (we use a non-allocated and non-compiled temporary "duplicate" `TaskFn` instance that is only useful for type inference in a const context). # Next Steps I believe we can remove the const `type_name` in favour of the const `type_id` and instead pull function names only when needed for display purposes. This will show up in a future PR. We can also remove non-const registration for things that aren't functions as well, though I believe this is less important. -
nextjs-bot authored
-
Hendrik Liebau authored
Stacked on #90613 When `@playwright/test` is available, the `instant()` helper now wraps its cookie-based lock acquire and release in `test.step()` calls. This surfaces "Acquire Instant Lock" and "Release Instant Lock" as distinct, labeled entries in the Playwright UI action list instead of anonymous `browserContext.addCookies` calls. `@playwright/test` is added as an optional peer dependency of `@next/playwright`. When it is not installed, the helper behaves exactly as before. Before: <img width="251" alt="before" src="https://github.com/user-attachments/assets/6c68b1d2-012d-4ff9-aa72-9f931dfe55ed" /> After: <img width="251" alt="after" src="https://github.com/user-attachments/assets/0156245d-b52f-4542-b22c-7d538aea5810" /> --------- Co-authored-by:
vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
-
Mitul Shah authored
Redesign the https://github.com/vercel/next.js/pull/87988 error pages to be more aligned with Next.js aesthetic, along with copy to be sharper. | Client | Server | |--------|--------| | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 26 07@2x" src="https://github.com/user-attachments/assets/f42bee3e-2ce8-44dc-9e26-79b81cf965d8" /> | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 23 38@2x" src="https://github.com/user-attachments/assets/19a596c6-6da7-4a42-9b53-16e3c2e6f867" /> | | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 25 22@2x" src="https://github.com/user-attachments/assets/a3075d79-c76a-4fbf-af6e-d4a44f1434eb" /> | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 24 17@2x" src="https://github.com/user-attachments/assets/5811cc98-f8e4-4451-bf9c-501548292245" /> | --------- Co-authored-by:
Jimmy Lai <laijimmy0@gmail.com> Co-authored-by:
Tim Neutkens <tim@timneutkens.nl>
-
Hichem authored
### What? Updated all proxy code examples in the API reference to use the `NextProxy` typed arrow function pattern, consistent with the convention used in `src/proxy.ts`. ### Why? The proxy function is typed as `NextProxy` so parameters are inferred from the type, removing the need for explicit `NextRequest` imports. ### How? Updated all proxy code examples in the API reference to use the `NextProxy` typed arrow function pattern, consistent with the convention used in `src/proxy.ts`. --------- Co-authored-by:
Joseph <sephxd1234@gmail.com> Co-authored-by:
Joseph <joseph.chamochumbi@vercel.com>
-
Luke Sandberg authored
We only store hashes for TaskTypes in the TaskCache keyspace, so this introduces an allocation free path to compute it. For writing out the TaskCache this wont make much of a difference since we were reusing a scratch buffer, but this should eliminate a source of allocations from the read path. This does of course cause a small binary size regression `157M (160,952K) -> 158M (161,800K) = +1M (+848K)`
-
nextjs-bot authored
-
- 03 Mar, 2026 11 commits
-
-
Jiachi Liu authored
-
nextjs-bot authored
-
Andrew Clark authored
Remove the `parallelRoutesKeys.length === 0` condition from `renderComponentsOnThisLevel` in walk-tree-with-flight-router-state. This check was added to support the behavior where clicking the same link twice forces all page segments to re-render on the server. This should no longer be necessary because the client already adds a refetch marker on those segments, so there's no need to special-case leaf segments on the server side.
-
Luke Sandberg authored
Save space in the persisent store by only recording TaskType one time instead of twice. ## What? Instead of using an encoded TaskType struct as a key in persistent storage just use a 64 bit hash. Now when looking up we actually need to do a cascading read * read task ids that match the hash * restore all the tasks until we find one that matches our CachedTaskType Full cache misses perform the same and so do cache hits since we always end up reading the TaskData anyway (in the `connect_child` operation that immediately follows). This just slightly changes _when_ that second read happens, as such we shouldn't really expect it to slow down. In the case of a hash collisions we do end up doing strictly more work (reading and restoring TaskData entries for the wrong task), but this work is cached and this should be _extremely_ rare assuming a good hash function.. From measuring vercel-site this saves ~231M of data in the persistent cache. (The cache goes from from 3846M -> 3615 or -231M or about -6%). Finally this also addresses a narrow race condition where two racing calls to `get_persistent_task_id` for the same task could result in two entries being pusshed to the `persistent_task_log`, that is now addressed as well. ## Why? Currently we encode 2 copies of every `CachedTaskType` in the database. 1. as the key of the `TaskType`->`TaskId` map (aka `TaskCache` keyspace) 2. as a part of the `TaskStorage` struct stored in the `TaskData` keyspace This redundancy is wasteful. Instead we can make the `TaskCache` map much smaller and add a bit of complexity to lookups. ## Future Work ### Better hash functions Right now to compute the hashes we are just running `encode` and then hashing the bytes. This is not optimal, but we do not have a hash function that is suitable for this usecase. So we should create a new `PersistentHash` trait that TaskInputs implement in order to support this without encoding. Or perhaps a custom _encoder_ that accumulates encoding data to a hasher. This will be addressed in https://github.com/vercel/next.js/pull/89059 ### New SST ffile heuristics now that the TaskcCache keyspace is smaller our heuristics on 'maxiumum number of keys in a file' need to be rethought since we are now producing lots of 7Mb files for the taskcache. this will be addressed in https://github.com/vercel/next.js/pull/89058 ### New compaction semantics Right now we tolerate duplicates in the database but compaction will delete them. This is not too harmful for us since it means if there is a hash coliision we will tend to lose one of the results over time. A better option would be to change compaction semantics for this KeySpace to either tolerate duplicates, leverage values for comparison, or something wilder where we simply 'recompute' the TaskCache instead of compacting it. This will be addressed in https://github.com/vercel/next.js/pull/89075
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack.
-
nextjs-bot authored
-
Jiachi Liu authored
-
Sebastian "Sebbie" Silbermann authored
Co-authored-by:
Vercel <vercel[bot]@users.noreply.github.com> Co-authored-by:
Cursor Agent <cursoragent@cursor.com>
-
nextjs-bot authored
-
Sebastian "Sebbie" Silbermann authored
-
Tobias Koppers authored
Turbopack: add anyhow::Context to turbo-persistence mmap, file open, and decompress operations (#90769) ### What? Adds `anyhow::Context` (`.context()` / `.with_context()`) to error-prone operations in the `turbo-persistence` crate: file opens, memory mapping (`mmap`), and LZ4 decompression. ### Why? `get` / `batch_get` sometimes fail with a bare "Cannot allocate memory" error, but the anyhow error chain has no context about *which* file, block, or operation caused it. This makes debugging difficult since the raw OS error propagates through bare `?` operators without any identifying information. ### How? Split double-`?` expressions (e.g. `Mmap::map(&File::open(&path)?)?`) into separate statements so each operation gets its own context. Added `.with_context()` to: - **`compression.rs`** — `decompress()` call in `decompress_into_arc()`, reporting compressed and uncompressed sizes - **`db.rs`** — `File::open`, `Mmap::map`, and `read_u32` in `read_blob()`, reporting the blob file path and size - **`static_sorted_file.rs`** — `File::open` and `Mmap::map` in `open_internal()`, `get_raw_block_slice` and `decompress_into_arc` in `read_block()`, and block offset reads in `get_raw_block_slice()`, reporting SST filename and block index - **`meta_file.rs`** — `options.map()` in `open_internal()`, reporting the meta file path An ENOMEM error will now produce a chain like: ``` Unable to open static sorted file 00000042.sst Caused by: Failed to mmap SST file /path/to/00000042.sst (1234567 bytes) Caused by: Cannot allocate memory (os error 12) ```
-