- 01 Aug, 2025 6 commits
-
-
nextjs-bot authored
-
Tobias Koppers authored
### What? We try to limit the maximum number of merge jobs with the `max_merge_segment_count` option. But as we run `get_merge_segments` for every key family it only limits the merge jobs per family. This results in much more merge jobs then configured. This change applied the limits across families. Lower number families will be compacted first, which is a new behavior, so maybe we want to reorder the key families to improve the order (see enum KeySpace)
-
Jarred Sumner authored
Fixes https://github.com/vercel/next.js/issues/75220 This marks Bun's builtin modules as external, following the same pattern as for Node. - `"bun:ffi"` - `"bun:jsc"` - `"bun:sqlite"` - `"bun:test"` - `"bun:wrap"` - `"bun"` I have not manually tested this change yet, nor attempted to write tests for this. I did check for other places in the code that should be updated and _maybe_ `externals/crates/next-custom-transforms/src/transforms/warn_for_edge_runtime.rs` should as well, but I'll leave that up to you whether or not that makes sense. Opening as a draft until this can be at least manually tested. By the way, node's `sqlite` module is missing from `NODE_EXTERNALS`. That seemed out of scope but worth mentioning. Current error message:  --------- Co-authored-by:
Alistair Smith <hi@alistair.sh>
-
Tobias Koppers authored
### What? No need to manually manage a free list, since mimalloc is able to handle this now
-
Tobias Koppers authored
### What? * Upgrade to mimalloc 3 * Compute allocations size more accurately (for tracing)
-
Luke Sandberg authored
Replace construction of `RcStr` instances on constant strings with the `rcstr!` macro which can shift construction costs to compile time and eliminate reference counting. Performance impacts from all the dropped ref counts are minor but do exist  There is also a small progression in max heap which makes sense, laying out the static rcstrs should be a somewhat easier job compared to mimalloc.
-
- 31 Jul, 2025 16 commits
-
-
nextjs-bot authored
-
Andrew Clark authored
This is part of a larger effort to remove dynamic params from server responses except in cases where they are needed to render a Server Component. If a param is not rendered by a Server Component, then it can be omitted from the cache key, and cached responses can be reused across pages with different param values. In this step, I've implemented client parsing of the params from the response headers. The basic approach is to split the URL into parts, then traverse the route tree to pick off the param values, taking care to skip over things like interception routes. Notably, this is not how the server parses param values. The server gets the params from the regex that's also used for routing. Originally, I thought I'd send the regex to the client and use it there, too. However, this ended up being needlessly complicated, because the server regexes are also used for things like interception route matching. But this is already encapsulated by the structure of the route tree. So it's easier to just walk the tree and pick off the params. My main hesitation is that this introduces some risk of drift between the server and client params parsing; we'll need to keep them in sync. However, I think the solution is actually to update the server to also pick the params off the URL, rather than use the ones passed from the base router. It's conceptually cleaner, since it's less likely that extra concerns from the base server leaking into the application layer. As an example, compare the code needed to get a catchall param value in the [client](https://github.com/acdlite/next.js/blob/09b16a816ff4d595b5111cb1a6de540838caf97e/packages/next/src/client/client-params.ts#L57-L61) versus the [server](https://github.com/acdlite/next.js/blob/09b16a816ff4d595b5111cb1a6de540838caf97e/packages/next/src/shared/lib/router/utils/get-dynamic-param.ts#L37-L84) implementation. Note: Although the ultimate goal is to remove the dynamic params from the response body (e.g. FlightRouterState), I have not done so yet this PR. The rest of the work will be split up into multiple subsequent PRs.
-
Janka Uryga authored
Initial implementation of runtime prefetching. A "runtime prefetch" is a more complete version of a static prefetch (i.e. the one that a link does by default), rendered on demand, and not cached server-side. It will render the server part of the page dynamically, allowing the usage of - `params` and `searchParams` - `cookies()` - `"use cache: private"` (these are omitted from static prerenders) - `"use cache"` with a short expire time (these are omitted from static prerenders) The result may be partial (in the PPR sense). It will exclude any parts of the page that depend on - uncached IO - `connection()`, `headers()` This allows the client router to cache the result, because it has a well-defined stale time. Note that public caches with a stale time below a certain fixed treshold will also be excluded, because it wouldn't make sense to keep them around in the router cache if we need to throw them away soon after getting them. With this PR, `<Link prefetch={true}>` changes meaning if `clientSegmentCache` + `cacheComponents` are enabled. It will now initiate a runtime prefetch instead of a "full" prefetch, which included everything that a navigation request would. Full prefetches can be done via `<Link prefetch="unstable_forceStale">`. If only one of the two flags is on, the behavior of `<Link prefetch={true}>` is unchanged from how it currently works. I've split the changes up into separate commits for ease of review: 1. Introducing the new workUnitStore type 2. Server - handling the prefetch header and rendering 3. Client - Link and segment cache changes ### Implementation notes The client router sends `next-router-prefetch: 2` to signal that it wants a runtime prefetch (as opposed to the old `next-router-prefetch: 1`, which is used for static prefetches). > NOTE: this builder change is required for this to work on vercel https://github.com/vercel/vercel/pull/13547. It was released in `vercel@44.6.5` Somewhat confusingly, in order to to avoid existing static prefetch codepaths, we need the server to _not_ treat this as "a prefetch request". Instead, we want to mostly treat this like we would a navigation request, and render dynamically. This means that: - `isPrefetchRequest` (from `parseRequestHeaders` in `app-render`) will be `false` - `getRequestMeta(req, 'isPrefetchRSCRequest')` won't be set This is a bit ugly but it works for now. I'll try to clean it up in the future. We render a payload of the same shape as a navigation request (including omitting shared layouts, as instructed by the `Next-Router-State-Tree` header). But unlike a navigation request, we do a cache-components-style prerender at runtime in order to exclude uncached/sync IO. This prerender uses a new workUnitStore type, `'prerender-runtime'`. This store type changes the behavior of `cookies()`, `params`, `searchParams`, `"use cache: private"`, `next/root-params`, and others. Unlike a static prerender, if we detect a bad uncached/sync IO usage, we just log an error (instead of throwing it and erroring) and respond with whatever we managed to render up until the render was aborted, in hopes that we can still return something useful to the client. This request is happening at runtime, so we should try to handle errors gracefully. We track whether or not the prerender has any dynamic holes, and if it does, set `x-nextjs-postponed: 1` on the response. This tells the client router if we still need to fetch more data when navigating, or if we can skip it because we already have a complete page. Ideally, we'd track this information per-segment for better reuse on the client side, but that's not in scope for this PR. We also set the `x-nextjs-staletime` header on the response to tell the client router how long it should keep this prefetch in the cache. Note that this does not affect `Cache-Control`, which should still be the same as a dynamic navigation request to prevent it from being cached by anything other than the client router. This may be improved in the future if it turns out we can safely set an appropriate `Cache-Control: private, ...` that also accounts for e.g. changing cookie values, but i'm erring on the side of caution for now. -
nextjs-bot authored
-
Joshua Hannaford authored
## Fix module reference handling in app_structure.rs creating duplicated layouts ### What? Fixed a bug in the `check_and_update_module_references` function by making the code always overrides the `not-found`, `unauthorized`, etc files at the top level group route layer. ### Why? The previous implementation had a bug that when a directory was setup like the added test case where the layouts from a lower directory would render when only the layouts at the level of the not-found page should have rendered. ### How? - Added the ability to force overriding of the `module` when running `check_and_update_module_references` - Split the logic between global and layer-specific modules Fixes #PACK-5081
-
Niklas Mischkulnig 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 ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### 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 # -->
-
Dario Lehmhus authored
Co-authored-by:Dario Lehmhus <dario.lehmhus@ffw.com>
-
nextjs-bot authored
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack. Co-authored-by:nextjs-bot <it+nextjs-bot@vercel.com>
-
Tobias Koppers authored
### What? This ensures next.js correctly waits for the turbopack shutdown to complete
-
Andrew Clark authored
This fixes an edge case where a Link is prefetched with prefetch={true}, and the target page has a dynamic head, but the head is not fully prefetched. If all the segment data for the target page was already cached, the prefetch scheduler would bail out and skip the request. However, we typically rely on the data prefetch to fetch the metadata, so by skipping the data prefetch we were effectively also skipping the metadata. The fix in this PR is to check for this condition before bailing out of the request, and initiate a request anyway. However, this illustrates that we're not modeling the caching of metadata in a complete way. Currently it's stored on the same cache entry as the route tree, but they are not always fetched simultaneously (as in this regression case), so their lifetimes are not always aligned. We should consider either always fetching the metadata as part of the route tree prefetch, or caching metadata on a separate entry type. This would allow us to dedupe entries between URLs that rewrite to the same route, like we already do for segments. The circumstances that lead to this scenario are relatively rare, though, hence the temporary solution in this PR. -
nextjs-bot authored
-
JJ Kasper authored
This reverts commit ac5fdf56. Reverts https://github.com/vercel/next.js/pull/82201 as our E2E deploy tests are still failing it seems. x-ref: https://github.com/vercel/next.js/actions/runs/16636039524/job/47078880946#step:33:321
-
JJ Kasper authored
It seems after landing this we have broken some integration with `jest` so reverting while we get to the bottom of what change in this commit specifically caused the breakage. x-ref: [slack thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1753911647161469)
-
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.
-
- 30 Jul, 2025 18 commits
-
-
nextjs-bot authored
-
Jiwon Choi authored
fix: display multiple lockfile warn if neither `outputFileTracingRoot` or `turbopack.root` option is provided (#82164) > Better to be reviewed with "Hide whitespace". This PR fixed a bug where `findRootDir()` was called and displayed multiple lockfile warnings even if the app had `turbopack.root`, as there was no `outputFileTracingRoot`. x-ref: https://github.com/vercel/next.js/pull/82164#discussion_r2240470772 Also, added information about the `outputFileTracingRoot` option and its docs to the warning, as it was omitted from https://github.com/vercel/next.js/pull/82052. Closes https://github.com/vercel/next.js/issues/81864 Closes https://github.com/vercel/next.js/issues/82096
-
Jiwon Choi authored
### Why? In `next dev`, `process.env.TURBOPACK` was set after `loadConfig`, which caused the `process.env.TURBOPACK` conditions within the initial `loadConfig` calls to be skipped unexpectedly.
-
Chad M Fennell authored
grammar nit: "an API" is singular Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
Shiro Wang authored
When I was using the standalone build, the second build would delete the contents of local packages. As a result, developers had to delete the cache of local empty directories and re-download the packages. I added a condition for recursive deletion to avoid this situation. Fixes #82157
-
Benjamin Woodruff authored
This feature is unused, but I think there are also significant problems with it, which would require work for it to be used: - The `Vec` isn't very scalable and that could be a footgun. It should be an `auto_hash_map::AutoSet` or a `FxHashSet`. - It's unclear that _just_ ignoring watch events is a good idea. I understand that we don't want to allow source code to depend on outputs, but it seems like it would be better to prevent reads in the first place in the `DiskFileSystem` (e.g. pretend the file doesn't exist and emit an issue). This would not require support from the watcher, as we just wouldn't create the invalidator at all. - There's no test coverage of this feature.
-
Benjamin Woodruff authored
This only impacts the non-recursive codepath. The notify-rs docs explain that you need to watch every parent of the file/directory you care about: https://docs.rs/notify/latest/notify/#parent-folder-deletion This reduces the missing invalidations on Linux detected by my fuzzer, but does not eliminate them: ``` rm -rf /tmp/fuzz && cargo run --release -p turbo-tasks-fuzz -- fs-watcher --fs-root /tmp/fuzz ```
-
Benjamin Woodruff authored
Turbopack: Use a BTreeMap in InvalidatorMap to avoid many `O(n)` traversals when finding child paths (#82133) This fixes an `O(n)` iteration of the invalidators (which can be quite large) in `invalidate_path_and_children_execute`. It requires the nightly `btree_cursors` API. It's possible to implement this without that API, but it'd be a lot less efficient, and I'm concerned about how hot this codepath might be. This codepath is used for both the recursive and non-recursive filesystem watcher, so it impacts all platforms.
-
nextjs-bot authored
-
Benjamin Woodruff authored
Common convention in our codebase is that `Path`/`PathBuf` are used for raw OS-level paths, and `RcStr` is used for normalized paths exposed by `turbo_tasks_fs`. These are raw OS paths, so we should use `Path`/`PathBuf`. This has some benefits in that it makes the implementation of https://github.com/vercel/next.js/pull/82133 easier, because `Path`'s `Ord` implementation is better for our use-case.
-
Jiachi Liu authored
-
Jiachi Liu authored
-
Janka Uryga authored
Accessing root params in a private cache should work, but I missed it in the `next/root-params` PR. ```tsx import { lang } from 'next/root-params' async function foo() { 'use cache: private' await lang() // this is okay } ``` With this PR, we'll now allow this (and `unstable_rootParams()`) -
nextjs-bot authored
-
Sebastian "Sebbie" Silbermann authored
-
Janka Uryga authored
we define most of the app router headers with capital letters, like this: ```ts export const NEXT_ROUTER_PREFETCH_HEADER = 'Next-Router-Prefetch' as const ``` which means we have to keep lowercasing the header everywhere when checking for its presence, because node and other intermediate layers normalize all headers to lowercase: ```ts if (req.headers[NEXT_ROUTER_PREFETCH_HEADER.toLowerCase()]) { ... } ``` this seems pretty pointless -- we can just define the headers in lowercase form, and skip all those `toLowerCase()` calls. (all the above sentences have been normalized to lowercase to match the spirit of this pr) -
Joseph authored
Closes: https://linear.app/vercel/issue/DOC-4930/notes-about-app-routers-react-version --------- Co-authored-by:
Rich Haines <hello@richardhaines.dev>
-
Joseph authored
This page https://nextjs.org/docs/app has too little actionable paths to go on
-