- 19 Oct, 2026 20 commits
-
-
next-js-bot[bot] authored
-
Niklas Mischkulnig authored
Revert part of #95732 This would cause a lot of worker pools to be created. Because `get_evaluate_pool()` takes as an argument the `additional_invalidation` and thus get a fresh worker pool per `additional_invalidation`
-
Andrew Clark authored
`await navigation()` prevents certain parts of a page from being rendered as part of a Link's prefetch (`<Link prefetch={true}>`). However, there are cases where you may wish to override that behavior and forcibly prefetch past that boundary. For example, if you have high confidence that the user will interact with a particular link. This PR adds three new options for a Link's prefetch prop: `"shell"`, `"prefetch"`, and `"navigation"`. `"shell"` and `"prefetch"` exist mostly for consistency — a value of `"shell"` has the same behavior as a missing prefetch prop, and `"prefetch"` has the same behavior as `true`. It's only `"navigation"` that introduces novel functionality. The naming scheme intentionally mirrors the `await prefetch()` and `await navigation()` APIs introduced in version 16.4. They correspond to the same conceptual stages. --------- Co-authored-by:Janka Uryga <lolzatu2@gmail.com>
-
Janka Uryga authored
fixes flakiness introduced in #100388. route trees expire after 5min by default, so they were occasionally causing the "no-requests" assertion (which we were doing after waiting for 5min) to fail in CI. we can avoid this by lowering the stale-time to 4min, which still validates that the cache's stale-time is being respected. (note that this means that the cache would be excluded from app shells. however, this test suite does not currently run in PPF, and has other tests that would have the same problem, so we'll have to deal with this later anyway)
-
Joseph authored
## Summary The `useSearchParams` docs say a prerendered route client-renders the tree up to the closest `<Suspense>` boundary. With Cache Components, that only holds when the rest of the route is prerendered. If any component on the route reads request data, such as `cookies()`, the postponed boundary is rendered on the server at request time with the real search params. Code inside it then runs on the server, and browser-only reads in render cause hydration mismatches. - `docs/01-app/03-api-reference/04-functions/use-search-params.mdx`: In Prerendering, state when the boundary is server-rendered under Cache Components, and point to `use(browser())` for browser-only components. - `errors/blocking-prerender-client-hook.mdx`: The Trade-off section said the fallback always swaps after hydration. Qualify it to routes where the rest is prerendered, and point to `use(browser())` for the request-time case. - `docs/01-app/02-guides/instant-navigation.mdx`: "suspends during server rendering" to "suspends during prerendering". Left unchanged: `errors/missing-suspense-with-csr-bailout.mdx`, which describes the non-Cache Components model and is accurate there. Finding: https://next-maintainer-agent.vercel.tools/agent-feedback/2121 ## Verification Production build on `next@16.4.0-canary.37` with `cacheComponents: true`, `curl "/<route>?q=hello"`: | Route | `useSearchParams` boundary in server HTML | | --- | --- | | Rest of the route prerendered | No, fallback only | | `cookies()` in a sibling `<Suspense>` | Yes, with `hello` | | `cookies()` awaited above the component | Yes, with `hello` | | Sibling `cookies()`, component calls `use(browser())` | No, sibling still streams | Matches `app-render.tsx`: a complete server result resumes and aborts postponed HTML boundaries into client render mode, a partial one saves postponed state for the request-time resume. Only `useSearchParams` was tested; the error page Trade-off covers the other URL hooks on the same code path. <!-- NEXT_JS_LLM -->
-
Janka Uryga authored
Since the introduction of `NavigationStatic`, the `Static` stage hasn't really been very useful, but we kept it as a "marker" stage that delineates where a static prerender ends (after `NavigationStatic`, containing all the finished accumulators). However, things get weird in the presence of caches with hanging inputs, because `createHangingInputAbortSignal` waits until `finalStage` (currently `Static`), which means that the keys for caches with hanging inputs would only finish in the `Static` stage. We were still running the `Static` stage in a separate task, before resolving the accumulators, so in practice this didn't cause any problems, but semantically we expect all userspace code to be done after the `NavigationStatic` task, and this behavior of caches breaks that expectation. I don't want to risk any weird staging bugs because of this, so removing `Static` seems like the easy choice.
-
Tobias Lins authored
**Cause** importing anything from next/server also loads connection(), which loads dynamic-rendering.ts. That file imported React at the top just to read an owner stack in development, and in a proxy build this pulled in the 688 KB app-page-turbo.runtime.prod.js. **Fix** React is now imported lazily. No public API change. Effect on a minimal proxy, on canary: the cold path goes from 53.8 ms to **39.1 ms (−27%)** and JS loaded from **1,466 KB to 748 KB**. The page runtime and React also drop out of middleware.js.nft.json, so the deployed proxy function is smaller. **Test** the new `test/production/app-dir/proxy-no-page-runtime` asserts the proxy's trace has no page runtime or React in it. It fails without the fix and passes with it on Turbopack and webpack. Existing tests that still pass: app-middleware-proxy and proxy-missing-export in production with Turbopack, and the cache-components-errors suites in dev with Turbopack. --------- Co-authored-by:Janka Uryga <lolzatu2@gmail.com>
-
Joseph authored
## Summary Adjusts the "rewritten" wording used in the `usePathname` rewrites section and the `blocking-prerender-client-hook` error page. The old text called the prerendered path the "source" and the browser URL the "rewritten" path, which reads backwards against the `source`/`destination` keys in the rewrites config. It now says the server renders the rewrite destination (for example `/blog/hello` for `app/blog/[slug]/page.tsx`) while the browser keeps the URL it requested, which is what `usePathname()` returns on the client. <!-- NEXT_JS_LLM -->
-
Tobias Koppers authored
### What? `useTempDir` (`test/lib/use-temp-dir.ts`) now deletes its temp directory with Node's native recursive `rm` (with `force` and `maxRetries: 10`) instead of fs-extra's `remove()`. If cleanup still fails after the retries, the error propagates and fails the test, as before. ### Why? `test/production/create-next-app/package-manager/pnpm.test.ts` flakes in the canary **test integration windows** job, usually on "should use pnpm for --use-pnpm flag with example" and sometimes on "should use pnpm when user-agent is pnpm". It normally passes on the in-job retry. create-next-app itself succeeds (`Success! Created use-pnpm-with-example …`). The test then hangs during cleanup until the 180 s timeout: ``` ● create-next-app with package manager pnpm › should use pnpm for --use-pnpm flag with example assert(received) Expected value to be equal to: true Received: false at fixWinEPERM (../node_modules/.pnpm/fs-extra@9.0.0/node_modules/fs-extra/lib/remove/rimraf.js:117:5) at ../node_modules/.pnpm/fs-extra@9.0.0/node_modules/fs-extra/lib/remove/rimraf.js:100:15 (x3) then: thrown: "Exceeded timeout of 180000 ms for a test." ``` Example logs: [job 114835938572](https://github.com/vercel/next.js/actions/runs/38255895288/job/114835938572) (lines with `fixWinEPERM`, followed by `finished on retry 1/2`) and [job 114820650313](https://github.com/vercel/next.js/actions/runs/38251637834/job/114820650313) (the user-agent case). Root cause: 1. Right after install or `git init` on Windows, a file in the project can be briefly locked (antivirus, indexer, or a lingering process), so `unlink` fails with `EPERM`. 2. On Windows, fs-extra@9's rimraf handles that in `fixWinEPERM`, which starts with `assert(er instanceof Error)` (rimraf.js:117). 3. Under Jest, Node-core fs errors are created in a different realm from the test's global `Error`, so `instanceof Error` is `false`. This is the known Jest cross-realm `instanceof` issue. 4. The assert throws inside the fs callback. The completion callback never runs, `remove()` never settles, and the test hangs until it times out. Node's built-in `rm` doesn't make that assertion. Its `maxRetries` option retries `EBUSY`/`EMFILE`/`ENFILE`/`ENOTEMPTY`/`EPERM` with a linear backoff (100 ms × attempt), which is intended for short-lived Windows locks like the ones in these logs. ### How? - Delete the directory with Node's native recursive, forced `rm`. This takes fs-extra out of the cleanup path and lets Node's own retry and backoff handle transient Windows locks. - Cleanup errors are not swallowed. A failure that outlasts the retries still rejects from the existing `finally`, so a real problem (e.g. a leaked handle) stays visible instead of turning into a silent leftover directory. - The signature, random path, `mode`, and `NEXT_TEST_SKIP_CLEANUP` behaviour are unchanged, so no caller needs changes. Known limitation: Node's rimraf runs its retry loop at every directory level, and parents retry on `EPERM`/`ENOTEMPTY` too. A transient lock clears quickly, but a lock that **persists** deep in `node_modules` can take much longer than 10 × backoff. This PR fixes the hang that never settles. It doesn't put an upper bound on cleanup time for locks that are never released. ### Verification On Linux, using scratch Jest 29 tests (not committed) against the real `test/lib/use-temp-dir.ts`: - **Reproduced the CI failure before the fix:** forced `process.platform = 'win32'` and injected one `EPERM` from the main realm into fs-extra's `unlink`. Cleanup failed with the same `assert` at `fixWinEPERM rimraf.js:117` and then hit the Jest timeout. - **After the fix:** 10/10 pass on **Node 20.9.0 (the CI version) and Node 24.14.1**: - the Windows-EPERM repro settles - two transient `EPERM`s injected into native `unlink` are retried, and the tree is removed (~310 ms, no warning) - a final `rm` rejection propagates out of `useTempDir` (no warning, no swallowing), including when the test body also threw - populated nested tree and symlink removal, the `rm` options, `NEXT_TEST_SKIP_CLEANUP`, and `mode` all behave as before - `prettier --check` and `eslint` on the changed file pass. Root `tsc --noEmit` reports no diagnostics in this file (other errors in the workspace come from unbuilt `next`). - Not run locally: real Windows. The **test integration windows** job on this PR is the confirmation. A single green run supports the fix but doesn't by itself prove the flake is gone. <!-- NEXT_JS_LLM --> <!-- fleet 5c4ff8b8-95e8-45ed-a98a-89c77031794d --> --------- Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Tobias Koppers authored
### What? Custom `installCommand`s in isolated test installs now run asynchronously with a hard deadline: 5 minutes by default, overridable with `NEXT_TEST_INSTALL_TIMEOUT_MS`. When the deadline fires, the command's whole process tree is killed before the install rejects with an error that includes the command and the deadline. ### Why? Some canary `build-and-test` jobs were cancelled at the 30-minute job limit while `test/e2e/yarn-pnp/test/with-sass` or `with-eslint` was still running. Normally these suites finish in 2–41s. Evidence: - [with-sass hang](https://github.com/vercel/next.js/actions/runs/38222505551/job/114722860774) - [with-eslint hang](https://github.com/vercel/next.js/actions/runs/38005869176/job/114075560853) These suites use a custom yarn install. `createNextInstall` ran that command with `execSync`, which blocks Jest's event loop, so the suite's 2-minute timeout could not fire while yarn was running. The buffered suite output was lost when the job was cancelled, so we can't prove which install step stalled. What this PR fixes is the verified mechanism that let a stalled custom install defeat Jest's deadline. #99827 has since added `timeout: 5 * 60 * 1000` to that `execSync` call, which caps the hang at 5 minutes. This PR replaces that call and goes further: - **Jest timeouts still fire.** The install no longer blocks the event loop, so hook and test timeouts can fire while yarn is running. - **The whole process tree is killed.** `execSync`'s timeout only sends SIGTERM to the `sh` child, so a `yarn`/`node` grandchild can keep running. This helper SIGKILLs the whole tree and waits for the kill to finish before rejecting. - **Clearer errors.** The error names the command and the deadline, and notes if killing the tree failed. - **Configurable.** The deadline can be changed with `NEXT_TEST_INSTALL_TIMEOUT_MS`; the default stays 5 minutes. ### How? - Replaced `execSync` (and its 5-minute `timeout` option) with a shell `spawn`. It keeps the same cwd, ignored stdin, inherited stdout/stderr, and the custom-install trace span. - Resolves on exit code 0. Rejects on a non-zero exit, a signal, a spawn error, or the deadline. - Accepts the env override only if it is a positive integer within Node's timer range. Otherwise the default is used. ### Verification - A local harness ran a shell command that starts a long-running grandchild. It showed that: - timers keep firing during the install - the 700ms deadline rejects - the grandchild is terminated - success, non-zero exit, and env override/fallback behave as expected - Prettier and ESLint on `test/lib/create-next-install.js`. - `tsc --noEmit -p tsconfig.json`: no errors in this file. The one remaining error, in `test/production/create-next-app/index.test.ts`, comes from my local worktree's outdated `packages/next/dist` build, not from this PR. - After rebasing onto canary 58f4af6a: the harness fails on canary as expected (`runCustomInstall` doesn't exist there) and passes on this branch. The module loads with canary's pnpm v12 settings and its `proper-lockfile` pack lock unchanged. - Not run locally: the real yarn PnP e2e suite. The sandbox has no Yarn registry egress; CI covers it. <!-- NEXT_JS_LLM --> <!-- fleet 167a7005-37a7-407d-950f-35e24969a548 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Tobias Koppers authored
## What? Fixes how the turbo-persistence README describes opening the database and reading from it. The old text said every SST file is memory mapped up front. ## Why? The old wording overstated how much memory opening a database costs. In the current implementation: - Opening the database loads only the meta files (memory mapped, or read into heap memory in `AccessMode::File`). It parses their AMQFs and filters out obsolete entries. SST and blob files are not opened. - An SST file is opened lazily, the first time a lookup gets past its hash-range and AMQF checks, and is then cached on its meta entry. - `AccessMode::File` never memory maps SST files. It keeps the block offset table on the heap and reads blocks with positioned reads. - In either mode, opening an SST reads and verifies only its index block. Key and value blocks are read when a lookup needs them. ## How? - Updates the **Opening** steps to match the directory-loading code. - Adds a short lifecycle explanation to **Reading**, covering both access modes and what drives memory cost. - Corrects the lookup outline: - adds the hash-range check - says the AMQF lives in the meta file - shows where the SST is opened Documentation only. The wording was checked against `Db::load_directory`, `MetaEntry::sst`, `MetaFile::lookup_entry` and `StaticSortedFile::open`. ## Verification - Stacked on #100310, which removes the README entry from `.prettierignore` and formats all READMEs. `npx prettier@3.6.2 --check turbopack/crates/turbo-persistence/README.md` passes. - `git diff --check` <!-- NEXT_JS_LLM --> <!-- fleet 9072af3c-95f7-4175-a93d-5b232fe92150 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
-
Tobias Koppers authored
## What? Anchors the `readme.md` rule in `.prettierignore` to the root symlink (`/readme.md`) and formats every README with Prettier, so that README files are covered by `pnpm prettier-check` and lint-staged. ## Why? The `readme.md` entry was meant for the root `readme.md` symlink. It isn't anchored, and Prettier matches ignore patterns case-insensitively, so it excluded every `README.md` in the repo (over 300 files). Those files were never format-checked, and about two dozen had drifted. ## How? - Anchors the entry as `/readme.md`, so it lists only the root symlink alongside the other `# Symlink files` entries and no longer matches nested READMEs. The entry documents the symlink rather than changing behavior: Prettier already skips symlinks when it expands a directory such as `prettier --check .`. The symlink's target, `packages/next/README.md`, is now formatted directly. - Runs Prettier 3.6.2 over all tracked README files. The changes are formatting only: - padding table separator rows - adding blank lines before lists and code blocks - changing `*emphasis*` to `_emphasis_` and `*` bullets to `-` - normalizing list indentation - removing one optional semicolon from a fenced JS example - No wording, links or code samples change in meaning. ## Verification - `npx --yes prettier@3.6.2 --check .` passes, as it did before the change. - Every tracked README passes `prettier --check`, and `--file-info` reports READMEs as no longer ignored. - `git diff --ignore-all-space --ignore-blank-lines` shows only Markdown normalization. <!-- NEXT_JS_LLM --> <!-- fleet 9072af3c-95f7-4175-a93d-5b232fe92150 --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Tobias Koppers authored
### What? In `next dev`, a Pages Router page could log a warning on initial load: `[HMR] Invalid message: {"type":"isrManifest",…} TypeError: Cannot read properties of undefined (reading 'components')`. This happens when the page entry loads slowly. Now the ISR manifest is stored until the router exists, and the static indicator is computed once the router has mounted. ### Why? The Pages Router HMR client opens its WebSocket before `hydrate()` creates the router. The server sends the ISR manifest as soon as the socket connects. `handleStaticIndicator()` then reads `window.next.router.components`, so it throws while the router is still `undefined`. This was the cause of the canary flakes in `test/e2e/i18n-support-base-path` ("should navigate with locale prop correctly" and its "locale false" / "GSP" variants) in the turbopack dev and cache-components dev jobs. Those tests check that no warnings were logged (`window.caughtWarns`). In the sampled canary logs, all 23 failed i18n-support-base-path test cases failed on this exact warning. Examples: [cache components dev](https://github.com/vercel/next.js/actions/runs/37933462646/job/113848439315), [turbopack dev](https://github.com/vercel/next.js/actions/runs/38014147874/job/114101474325). ### How? - `handleStaticIndicator()` returns early until `window.next.router` exists. The manifest is still saved in `isrManifest`. - The Pages dev overlay bridge calls `handleStaticIndicator()` once on mount, as well as on `routeChangeComplete`. Without this, the guard would leave the initial indicator unset. - New regression test: it holds the page entry chunk until Playwright sees the `isrManifest` WebSocket frame. That forces the manifest to arrive before the router exists, every time. The test asserts that no `[HMR] Invalid message` warning is logged and that the indicator shows `Dynamic` for a `getServerSideProps` page. ### Verification - New test: fails before the fix with the CI error. Passes after the fix with `pnpm test-dev-turbo` and `pnpm test-dev-webpack`. - With only the guard and without the on-mount call, the new test fails (indicator is `undefined` instead of `Dynamic`). - `test/development/dev-indicator/dev-indicator.test.ts` passes in turbopack dev (21/21). - `test/e2e/i18n-support-base-path` locale navigation tests pass in turbopack dev, with and without `__NEXT_CACHE_COMPONENTS=true`. <!-- NEXT_JS_LLM --> <!-- fleet 8ed51691-b715-4d15-8574-79aa8e971ffd --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Niklas Mischkulnig authored
Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
-
Luke Sandberg authored
It's been flaky for >1 week most recently https://github.com/vercel/next.js/actions/runs/39080310443/attempts/2
-
Niklas Mischkulnig authored
react-virtualized v10 was just released, the test didn't pin the version: ``` ▲ Next.js 16.5.0-canary.17 (webpack) ✓ Running next.config took 12ms - Experiments (use with caution): ✓ strictRouteTypes (enabled by `__NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES`) Running TypeScript ... Finished TypeScript in 1ms ... Creating an optimized production build ...
⚠ Compiled with warnings in 1436ms ./pages/index.js Attempted import error: 'WindowScroller' is not exported from 'react-virtualized' (imported as 'WindowScroller'). ./pages/index.js Attempted import error: 'List' is not exported from 'react-virtualized' (imported as 'VirtualizedList'). ✓ Compiled successfully in 2.7s Collecting page data using 5 workers ... Generating static pages using 5 workers (0/3) ... Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. at ignore-listed frames Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. at ignore-listed frames Export encountered an error on /, exiting the build. ⨯ Next.js build worker exited with code: 1 and signal: null console.log running pnpm next build at NextStartInstance.log [as start] (lib/next-modes/next-start.ts:125:15) ``` -
Tobias Koppers authored
### What? Use [`os.availableParallelism()`](https://nodejs.org/api/os.html#osavailableparallelism) instead of `os.cpus().length` wherever we need a CPU count: - default `experimental.cpus` (build worker count) - `next info` CPU cores output - dev server trace span and trace upload `cpus` metadata - anonymous telemetry `cpuCount` - devlow-bench `NUM_CPUS` ### Why? `os.cpus().length` reports every logical CPU on the host and can be `0` on some platforms. `os.availableParallelism()` estimates the parallelism actually available to the process, respecting CPU affinity, and always returns at least 1. That avoids spawning more workers than the process can effectively use on constrained machines and in containers. ### How? - The worker default keeps its existing policy (`CIRCLE_NODE_TOTAL` override, subtract one, minimum of one). The `os.cpus() || { length: 1 }` fallback is no longer needed, because the API always returns at least 1 and our Node.js minimum (20.9) supports it. - Reporting and telemetry fields keep their names and types. On constrained machines their values may now be lower, reflecting the usable parallelism. - `os.cpus()` stays where we need CPU model or speed information rather than a count. <!-- NEXT_JS_LLM --> <!-- fleet 7744136c-2fb5-4473-b310-b34f7d603506 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Luke Sandberg authored
### What? Reads each SST's block-offset table and index block once at open, with positional reads, store the data in a heap buffer, instead of dereferencing the mmap The offset table becomes a validated `BlockOffsets` value. Lookup handles keep the index block as an owned array of entries. Both are owned outside the backing enums. ### Why? Every block access needs two offset-table entries, and every lookup binary searches the index block. Reading both with `pread` and keeping them in memory means locating a block never reads either of them through the mmap. Currently the offset block is advised as `WILLNEED` on open, but this is not sufficient, it will ensure it is quickly availble after startup, but the memory remains `madvise(RANDOM)` so it does not participate in recency accounting. However, these are the hottest blocks in any SST since all accesses reference them. Alternatively we could `madvise(DEFAULT)` this range, but the `pread` is more accurate (our data is not page aligned anyway, but the pread is perfectly accurate The difference will probably only matter if mmap table pages are being reclaimed. <!-- fleet 5f39f2b2-0882-4566-ae42-cf64574c5747 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Tobias Koppers authored
### What? Interns the merge bitmaps in `compute_merged_modules` (turbopack-core, `module_graph/merged_modules.rs`). Each distinct `RoaringBitmapWrapper` gets a dense `u32` id once, after the fixed-point traversal. The `map chunk groups` and `exposed computation` traversals then key `chunk_lists` by that id and compare ids instead of bitmaps. This is the first of three stacked PRs that speed up `compute_merged_modules`: 1. intern bitmaps (this PR) 2. parallel merge of the chunk group lists (#100237) 3. reconciliation shortcuts (#100238) ### Why? `map chunk groups` visits every module of every chunk group (about 19.8 M visits on the bench app below). On each visit, the old code: - looked up `chunk_lists: FxHashMap<&RoaringBitmapWrapper, _>`, where `RoaringBitmapWrapper::hash` serializes the whole bitmap into the hasher; - compared the parent's and the child's bitmaps. In a CPU profile, `serialize_into` under that hash accounted for about two thirds of the phase's samples. ### How? - **`intern_bitmaps`:** a small private helper that maps each key to the id of its bitmap. Equal bitmaps (by `RoaringBitmapWrapper`'s `Eq`) get the same id. - **Equivalence:** id equality is exactly bitmap equality, so the lists, their order and the output are unchanged. - **Tracing:** an `intern bitmaps` span shows the cost of interning (~35 ms on the bench app). ### Results Bench app `bench/nested-deps-app-router-many-pages` at 32 CPUs: - **Builds:** cold `next build` with `taskset 0-31` and `TURBO_TASKS_AVAILABLE_PARALLELISM=32`, using release binaries built at the base commit (`6dda4371`) with and without this change. - **Rounds:** 1 warm-up per arm, then 4 rounds in alternating order. - **Phase times:** read from the `overview` light trace. | Metric (s) | canary median | this PR median | Median paired change | Faster in | |---|---:|---:|---:|---:| | Wall | 54.72 | 53.13 | −4.7% | 4/4 | | "Compiled in" | 34.45 | 31.45 | −10.0% | 4/4 | | `compute merged modules` | 6.64 | 4.10 | −38.8% | 4/4 | | `map chunk groups` | 3.14 | 0.49 | −84.3% | 4/4 | | `merging chunk group lists` | 1.73 | 1.79 | +0.5% | 2/4 | | `reconciliation` | 0.93 | 0.94 | +0.6% | 2/4 | <details><summary>Per round (canary → this PR)</summary> | Round | Order | Wall | "Compiled in" | `compute merged modules` | `map chunk groups` | `merging chunk group lists` | `reconciliation` | |---|---|---:|---:|---:|---:|---:|---:| | 1 | canary first | 53.70 → 50.20 | 33.80 → 29.80 | 6.56 → 4.09 | 3.20 → 0.54 | 1.62 → 1.78 | 0.92 → 0.93 | | 2 | this PR first | 54.55 → 52.93 | 35.10 → 30.90 | 6.72 → 4.10 | 3.08 → 0.46 | 1.81 → 1.79 | 0.96 → 0.96 | | 3 | canary first | 54.89 → 53.33 | 33.30 → 32.00 | 6.48 → 3.88 | 3.01 → 0.48 | 1.65 → 1.67 | 0.92 → 0.91 | | 4 | this PR first | 58.91 → 54.70 | 35.70 → 32.80 | 7.08 → 4.35 | 3.27 → 0.50 | 1.91 → 1.91 | 0.94 → 0.95 | </details> - **Limits:** one VM, one app, 4 rounds, and no significance test. The light trace adds some overhead to every arm. - **Output:** the `.next` output (71,117 files) is identical to canary's. Only the per-build random preview-mode and server-action keys differ. ### Verification - New unit test `intern_bitmaps_gives_equal_bitmaps_equal_ids` (equal bitmaps built in a different order, different bitmaps, empty bitmaps, dense ids). - `cargo test -p turbopack-core` - `cargo test -p turbopack-tests --test snapshot --test execution -- scope_hoisting` (2 snapshot and 52 execution fixtures, with unchanged snapshots) - `cargo clippy -p turbopack-core --all-targets -- -D warnings` <!-- NEXT_JS_LLM --> <!-- fleet d8fee2f9-18db-4936-b59a-f8417b8f4bbc --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Tobias Koppers authored
### What? Turbopack scope hoisting no longer merges modules that contain a direct `eval(...)` call. Such modules are emitted as their own module factories, and the rest of the graph is still merged. ### Why? Merging puts modules into one shared scope and renames colliding top-level bindings. A direct `eval` resolves names at runtime against its lexical scope, so after a rename it can read the wrong binding. For example, `eval('local')` can return another module's `local`, or throw. ### How? - **Detection:** while building the analyzer's variable graph, each call expression is checked. If the callee (with parentheses stripped) is the unresolved global `eval` identifier, a module-wide flag is set. Nested functions, classes and IIFEs are covered. - **What doesn't count:** indirect forms leave the module mergeable. These are `(0, eval)(…)`, `globalThis.eval(…)`, `eval?.(…)`, aliases, `new eval(…)`, and a locally bound `eval`. - **Plumbing:** the flag is passed into the module analysis result, and `EcmascriptModuleAsset::is_mergeable` returns `false` when it is set. The existing rule that only ESM modules are mergeable is unchanged. - **Split modules:** a module with exports can be split into a facade plus a `<locals>` module. The `<locals>` module carries the original code but used the trait's default `is_mergeable`, which is always `true`, so it would have bypassed the opt-out. It now uses the original module's answer. ### Tests - **Analyzer unit test:** covers direct, indirect and shadowed `eval` forms. It includes sloppy-script shadowing, which strict ESM can't express. - **Snapshot `scope-hoisting/direct-eval`:** the module with a direct `eval` stays separate, while the module that only uses indirect `eval` is still merged. - **Execution test `scope-hoisting/direct-eval`:** a merge would rename the `eval` module's colliding local. With the opt-out disabled, the test fails (`"other"` instead of `"direct"`). <!-- NEXT_JS_LLM --> <!-- fleet 1ab5c143-50eb-4959-abe0-907ef30c1402 --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
- 17 Oct, 2026 1 commit
-
-
next-js-bot[bot] authored
-
- 16 Oct, 2026 9 commits
-
-
Luke Sandberg authored
### What? turbo-persistence SST lookup mappings keep `MADV_RANDOM`, and also prefetch whole multi-page blocks: - **Block hint:** before a block's first full read in an SST open (CRC check and decompression), the block's page-aligned range gets `MADV_WILLNEED`. The hint is issued before any byte of the block is read, header included, and only when the block spans more than one page (using the system page size). - Medium value blocks bypass the block cache, so they get the hint on every read. - Already-verified blocks and single-page blocks get no syscall. - **Block-offset table:** gets `MADV_WILLNEED` at open, instead of `MADV_SEQUENTIAL`. - **Unknown page size:** if `sysconf(_SC_PAGESIZE)` fails, block hints can't be computed, so `MADV_RANDOM` isn't applied either and the mapping keeps default advice (read-around still prefetches). The offset-table hint is applied in both cases. - **Unchanged:** compaction iteration (`MADV_SEQUENTIAL`), meta/blob files, File access mode, non-Unix platforms and the on-disk format. ### Why? See #100250. - With `MADV_RANDOM` alone, a cold multi-page block is faulted in one page at a time. - Dropping the advice (the first version of this PR) lets kernel read-around fix that, but it also reads neighboring blocks that are often never used. The two variants were compared on a real workload: - **Setup:** warm `next build`s of `bench/nested-deps-app-router-many-pages`, with a new `NEXT_DEPLOYMENT_ID` each build. The cache snapshot contained fresh, compacted, hot_bottom and cold_bottom SSTs. - **Runs:** cold guest page cache, Linux, 4 KiB pages, 5 rotated trials per variant. | Variant | Median build | Major faults | Cache resident after | | --- | --- | --- | --- | | canary (`Random`) | 40.0 s | ~101k | 527 MiB | | default advice | 39.6 s | ~14.2k | 545 MiB | | `Random` + `WillNeed` everywhere (this PR) | 38.2 s | ~13.4k | 527 MiB | | `WillNeed` for cold_bottom only, default for the rest | 38.8 s | ~13.8k | 533 MiB | - Build times are within run-to-run noise. Cache reads are a small part of this build, so this is not a claimed wall-time win. - The targeted hints match default advice's fault reduction, with less data pulled into the page cache. - Reading unneeded pages costs more on slow or compressed backing storage such as squashfs. That is another reason to avoid read-around, though it wasn't benchmarked here. - Not measured: memory pressure, macOS and 16 KiB pages. With 16 KiB pages more blocks fit in one page and get no hint. ### How? - `get_raw_block_slice` takes a `will_need` flag and issues the hint after locating the block, before reading its header. - Lookups pass `true` when the block's verified-CRC bit is unset; the index block and medium values always pass `true`; iteration passes `false`. - Adds a `libc` dependency on Unix for `sysconf(_SC_PAGESIZE)`, queried once and cached. If it can't be determined, both the block hints and `MADV_RANDOM` are skipped. - Tests: - Linux `/proc/self/smaps` check that lookup mappings carry `rr` and not `sr`; - a test-only hint log verifying the offset-table hint, multi-page-only first-read hints, no hints on re-reads, and per-read medium-value hints; - pure page-boundary tests for 4 KiB and 16 KiB. - README documents the advice policy. <!-- NEXT_JS_LLM --> <!-- fleet 5f39f2b2-0882-4566-ae42-cf64574c5747 --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
-
next-js-bot[bot] authored
-
Luke Sandberg authored
## Summary `cached navigations › caches params from a cold RSC navigation for repeated navigations` was gated with `@gate !deploy || adapter` because the legacy Vercel builder incorrectly prerenders params omitted from `generateStaticParams`. The old version of the test asserted that the omitted `bottom` param was *not* cached on repeat navigations, which the legacy builder violated. #99617 rewrote the test to assert the opposite: repeat navigations to `/required-fallback-params/t2/b1` now expect `Bottom: b1` to be served from the cache, plus a new check that a different param (`b2`) still shows its loading boundary. Both hold on the legacy builder, so the inverted gate now fails the deploy suite with "Failing test passed even though it was supposed to fail" on both Webpack and Turbopack (e.g. the [v16.5.0-canary.15 deploy run](https://github.com/vercel/next.js/actions/runs/38825363975/job/116760175009)). This removes the stale gate so the test runs as a normal assertion in deploy mode. ## Verification - Not run: deploy tests locally (requires Vercel deploy credentials); the linked deploy run shows the test passing on both bundlers once the gate inversion is ignored. <!-- NEXT_JS_LLM -->
-
Andrew Clark authored
This is a refactor of the FetchStrategy type. As the Partial Prefetching design has evolved, FetchStrategy has come to represent two independent concepts, which we now model separately: the _stage_ (AppStage) of the navigation that an entry was rendered through (shell, prefetch, or navigation), and the _completeness_ (Completeness) of the rendering through that stage (needs runtime request, cache complete but with dynamic holes, or fully complete with no dynamic holes). Everywhere that used to accept a FetchStrategy now accepts either one or both of these types. (Note: I've called the type AppStage to distinguish it from the internal stages used on the server as part of the rendering algorithm. The stages used on the client are the ones we document publicly as part of `ensureStatic` and the `prefetch()` and `navigation()` APIs.) The `completeness` field also replaces the `isPartial` field. It's possible to express much of the logic using a single enum, as in the FetchStrategy model. To prove this, I've extracted most of the behavioral changes into earlier PRs, to make this one easier to review. But the resulting logic in the new model should be easier to follow. So on net, we have the same number of fields but expressed in a way that better fits the underlying design: - Every prefetch task (e.g. a visible Link) has a target stage and level of completeness. The task finishes when the cache has entries that match _both_ targets. - When deciding whether to overwrite an existing entry, a more less complete entry must never overwrite a less complete one, even if it represents a later rendering stage. For example, a response rendered at the Navigation stage cannot overwrite a response written at the Prefetch stage if it does not include cookie-dependent data; we must discard it and perform a new request. --------- Co-authored-by:sparkly-dev <338975655+sparkly-dev@users.noreply.github.com>
-
Jan Kassens authored
# Human Notes This deletes some code that appears to be dead but would otherwise need to be updated as we refactor other code nearby to pull out `request` and `response` from inner functions. # AI ## Summary `NextNodeServer.renderHTML` (and its abstract declaration on `BaseServer`) has had no callers since #81944, which removed the last call site. Nothing else in `packages/` or `test/` references it. This removes the method along with everything only it used: - `lazyRenderAppPage` in `route-modules/app-page/module.render.ts`. `lazyPrerenderAppPage` stays because export uses it. - The `NextNodeServerSpan.renderHTML` trace span constant. It is no longer emitted and is not in either span allowlist. - `renderOpts.isPossibleServerAction`. `renderHTML` was its only reader. The App Router renderer reads `isPossibleServerAction` from its render context, not from `renderOpts`, so the Node and Edge templates no longer need to write it. The Pages `RenderOpts` field is unchanged. This is not public API. The `next()` custom-server wrapper (`NextServer` in `server/next.ts`) never forwarded `renderHTML`; it only exposes the already-deprecated `render`, `renderToHTML`, `renderError`, `renderErrorToHTML` and `render404`. The method is `protected` on both server classes, and the only way to reach it is by subclassing `NextNodeServer` from `next/dist`. An override there has not run since #81944, because nothing calls the method. The span name is not in the span allowlists or the docs, and has not been emitted since the same PR. There is no behavior change. This also means the App page render inputs have one fewer producer to keep in sync when they change. ## Verification - `tsc --noEmit` for `packages/next`: no errors - ESLint and Prettier on the changed files - Not run: e2e tests (the deleted code had no callers, so CI covers it) <!-- NEXT_JS_LLM --> --------- Co-authored-by:Claude Opus 5.5 <noreply@anthropic.com>
-
Jan Kassens authored
## Summary Pass the existing Server Action classification result into App Router rendering instead of repeatedly inspecting the request. `ServerActionRequestMetadata` now flows from Node, Edge, direct-server, and export adapters through render preparation and action dispatch; `prepareAppPage` no longer needs the request object. Classification rules and action execution behavior are unchanged. This continues the request/response boundary cleanup in #99269. ## Verification Validated on the exact #99269 base: the Node/Edge unrecognized-action suite passed in Turbopack development and Webpack production (26 tests each), plus standalone Server Actions in Turbopack production (2 tests). <!-- NEXT_JS_LLM -->
-
Jiwon Choi authored
### Why? pnpm rejects symlinked task-state paths, so the upgrade evals fail while preparing the stable candidate build. ### How? Create a real `node_modules` directory in the isolated checkout and link the installed dependency entries into it. Leave pnpm task state local to that checkout.
-
Tobias Koppers authored
Revert #100136
-
Jiwon Choi authored
### Why? `next upgrade --agent` pins the latest canary without considering the package manager's minimum release age, so its delegated CLI can conflict with the configured policy. ### How? Read npm, pnpm, and Yarn release-age settings and relevant exclusions, then pin the highest eligible canary at or below the fetched canary tag. Keep the delegated CLI's exact-version guard and stop when settings or metadata cannot be read or no eligible canary exists. For npm, use merged JSON settings with `before` taking precedence over `min-release-age`. For pnpm, interpret only the first exclusion matching `next`. Read Yarn's effective settings directly. Metadata queries use the package manager's normal cache behavior, including cached responses when available.
-
- 15 Oct, 2026 10 commits
-
-
next-js-bot[bot] authored
-
Josh Story authored
## Summary Pass the final app-page request URL explicitly from the Node, Edge, and build export entry points into rendering. This keeps URL parsing and the deterministic prerender request ID tied to the exact URL observed on the request after existing normalization. Development ISR status bookkeeping uses the forwarded URL with its existing URL parsing behavior. A path-scoped lint guard prevents new direct `req.url` reads in app-render. ## Verification - `pnpm --filter=next types` - `pnpm --filter=next build` - Confirmed `rg -n '\breq\.url\b' packages/next/src/server/app-render` has no matches. - ESLint stdin probes reject `req.url` under app-render with the `requestUrl` guidance and allow the same access outside app-render. - Not run: integration tests (the worktree lacks per-package dependencies, so the full bootstrap build could not complete). <!-- NEXT_JS_LLM -->
-
Sam Selikoff authored
Hide "Open in editor" button text on small screens. Follow-up to #100206. <!-- NEXT_JS_LLM -->
-
Niklas Mischkulnig authored
Basically reverts https://github.com/vercel/next.js/pull/63683 API routes don't have "parent layouts" and shouldn't inherit their config from anywhere
-
Niklas Mischkulnig authored
Add some regression tests about the current behavior Mostly - inheritance across layouts and parallel routes - API routes Turbopack is currently wrong for some of those. See PRs up the stack
-
Andrew Clark authored
If an entry is not partial, it means nothing was omittted during rendering. Regardless of the strategy used to fetch it — static vs dynamic, shell vs prefetch vs navigation, etc — it's the most complete possible representation of the data. No other fetch strategy could return a more complete version. This PR updates the precedence logic to take `isPartial` into account. I discovered this while working on the next PR, which replaces `isPartial` with a new "completeness" concept. I extracted it into this earlier PR to show how it would be expressed in the current model, so the next one is easier to review.
-
Andrew Clark authored
A navigation response that includes dynamic data should not report any vary params, because (until the Ledgers feature lands in React), we cannot track params during a streaming render. This updates the server to send `null`, which represents an unknown set of params. The previous structure was mostly harmless because the client only uses the vary params when writing to its local cache, and navigation responses are not written to the cache (except when they are fully static). The one exception is when performing a full prefetch when Partial Prefetching is not enabled — the client had a special case to ignore the (bogus) vary params sent by the server and treat them as unknown. The special case is no longer necessary after this fix. Now the server's vary params can be treated as authoritative in all cases without special handling on the client.
-
Andrew Clark authored
Fixes a few oversights in the Partial Prefetching implementation that I discovered while working on a larger refactor. I've moved these into a separate PR so they can be reviewed independently of the upcoming restructuring. These can be reviewed commit-by-commit.
-
Andrew Clark authored
Fixes an oversight in the Cached Navigations implementation where a fully cached navigation response was written into the cache without also extracting and writing its shell.
-
Andrew Clark authored
Navigation and prefetch requests go through `createFetch`, which had grown several jobs beyond fetching. It decoded navigation responses itself (so React DevTools could time the request from the moment it was sent), with a flag for prefetches to opt out and a separate wrapper stream for HMR refreshes that can be superseded. With Cache Components, it also stripped the leading partial marker byte by rebuilding the Response around the stripped stream, and tee'd every response so a full prefetch could cut its shell from a second copy of the body. Every caller paid for the tee and the rebuilt Response, including ones that never needed them. This PR untangles those layers. Each commit can be reviewed on its own. This is mostly a restructuring, to make the subsequent PRs in the stack easier. No meaningful outward behavior changes.
-