- 21 May, 2026 15 commits
-
-
next-js-bot[bot] authored
-
Benjamin Woodruff authored
By default, turbo-tasks will try to use every available CPU core. While we do want it to use as many resources as possible if the CPU is otherwise idle, this may hurt us when the CPU is busy, as it will lead to more locking, more thread contention, more memory usage, etc. **This environment variable does not strictly limit Turbopack to using 4 cores, it just restricts the number of main tokio worker threads and changes how we shard dashmaps.** We currently are using 16 core CI machines, but I want to experiment with 32 core build machines with a higher `TEST_CONCURRENCY`, and the per-core scaling of Turbopack was a concern that came up, as wall time improvements are sub-linear starting somewhere around 16 cores. ## Test Plan Watch CI, compare build times in this commit and the parent one. Attempt with a value of 2: https://github.com/vercel/next.js/pull/94001 Attempt with a value of 8: https://github.com/vercel/next.js/pull/94002  I think this data is too noisy to draw any conclusions.
-
Vercel Release Bot authored
This auto-generated PR updates font data with latest available Co-authored-by:next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
-
Andrew Clark authored
Turns on `experimental.cachedNavigations` by default for projects already on `cacheComponents`. Last of the Sparkle stack. Tied to `cacheComponents` rather than flipped unconditionally because `cachedNavigations` is a no-op without it, and the existing validation already throws if you set it without `cacheComponents` — so an unconditional flip would break every non-Cache-Components project. <!-- NEXT_JS_LLM_PR -->
-
Andrew Clark authored
Turns on `experimental.optimisticRouting` by default. Second of the Sparkle stack. A few tests pin `optimisticRouting: false` because their assertions observe the pre-flip navigation timing — search-params, a11y route announcer, and hash scroll. To be updated separately. <!-- NEXT_JS_LLM_PR -->
-
Andrew Clark authored
Turns on `experimental.varyParams` by default. First of a short stack flipping the remaining Sparkle flags to their new defaults — landing one flag at a time so any regressions are bisectable. A test in `segment-cache/prefetch-runtime` asserts on the pre-flip root-param cache-keying; pinned to `varyParams: false` until the test catches up. <!-- NEXT_JS_LLM_PR -->
-
Josh Story authored
-
Luke Sandberg authored
### What? When `node_modules/next` is briefly unresolvable mid-session (for example because pnpm is mid-install of a package with a `next` peer dependency, reshuffling its symlinks) Turbopack would: - Emit a `MissingNextFolderIssue` with severity `Fatal` - Propagate `anyhow!("Next.js package not found")` through ~10 levels of the build graph - Surface the failure at the napi boundary as a `TurbopackInternalError`, which the Next.js JS-side treats as fatal and shuts the dev server down The reported user impact was a dev session that became wedged and could not recover even after restarting `next dev`, because the persistent cache had stored the failed operation state. Users reported it as "stuck", "catastrophic", and required wiping `.next/` to recover. Unfortunately while i was able to reproduce a number of bad outcomes, i couldn't actually reproduce the issue of `next dev` getting stuck in a bad state. Still this PR will improve a number of apis and error messages See internal discussion: https://vercel.slack.com/archives/C046HAU4H7F/p1778792876550309 ### Why? A transient filesystem race during an install is the canonical recoverable error — once the install finishes, `next` is resolvable again. There is no reason this should bring down the dev server or poison the persistent cache. The bug had two contributing causes: 1. The error message was poor. It assumed the only cause was a mis-set `turbopack.root`, with the entire message in `title()`. It didn't acknowledge the install-race case or any of the other realistic causes (broken symlink, monorepo hoisting, removed `node_modules/next`, global install). Users had no way to know that the right response was to wait or refresh. 2. The Rust→napi boundary did not treat this as a recoverable error. Two specific code paths propagated `Err` instead of catching it: - `issue_filter_from_endpoint` in `endpoint.rs` calls `endpoint_op.connect().await?` — if the upstream endpoint resolution errors (as it does when `directory_tree_to_loader_tree` fails), this `?` propagates **before** the surrounding `strongly_consistent_catch_collectables` gets a chance to convert the failure into Issues. - `Project::hmr_version_state` is called bare from `project_hmr_events` at the napi boundary. There is no `_with_issues_operation` wrapper, so any error from the underlying `hmr_content`/`versioned_content_map.compute_entry` chain propagates straight to JS. ### How? Three changes: **1. Rewrite `MissingNextFolderIssue`** ([next_import_map.rs](crates/next-core/src/next_import_map.rs)) - Severity downgraded from `Fatal` to `Error`. `Fatal` triggers an explicit JS-side server shutdown in `print-build-errors.ts`; `Error` lets the dev server recover. - Title is a single line: `"Could not find the Next.js package (next/package.json)"`. - Description lists all realistic causes (concurrent install, missing/broken symlink, mis-set workspace root, monorepo hoisting, global install). - Doc link moved to `documentation_link()` so it doesn't pollute the inline message. **2. Make `issue_filter_from_endpoint` Err-tolerant** ([endpoint.rs](crates/next-napi-bindings/src/next_api/endpoint.rs)) - Wrap the `endpoint_op.connect().await` in a `match` and fall back to `IssueFilter::warnings_and_foreign_errors()` on `Err`. - This unblocks the existing `strongly_consistent_catch_collectables` recovery path, which then absorbs the upstream failure as Issues that surface through the napi boundary normally. **3. Add `hmr_version_state_with_issues_operation`** ([project.rs](crates/next-napi-bindings/src/next_api/project.rs)) - Mirrors the existing `hmr_update_with_issues_operation` pattern. - Drives `hmr_version_operation` as an `OperationVc`, catches any `Err` and falls back to `NotFoundVersion`, and collects issues from the operation via `peek_issues`. - The napi `project_hmr_events` handler now uses this wrapper instead of calling `Project::hmr_version_state` bare. Issues from both `hmr_version_state` and `hmr_update` are merged before being sent to JS. - Required lifting the inner `hmr_version_operation` out of `Project::hmr_version_state`'s closure to make it callable from the napi layer. A new regression test at [test/development/app-dir/concurrent-install/](test/development/app-dir/concurrent-install/) reproduces the failure by moving `node_modules/next` aside mid-HMR-session and asserts that the dev server does not emit `FATAL: An unexpected Turbopack error occurred` or `TurbopackInternalError`, and that the friendly Issue text surfaces. The test is skipped under `NEXT_SKIP_ISOLATE=1` since that mode doesn't produce a manipulable `node_modules`. Out of scope: after recovery, the dev server still returns 500 on subsequent requests until the user manually refreshes (the JS-side per-route error state isn't invalidated by Turbopack's successful recompile). That's a separate dev-server caching issue. <!-- NEXT_JS_LLM_PR --> -
Niklas Mischkulnig authored
-
Luke Sandberg authored
Fix the `leftover tokens` issue we have been getting from rust-analyzer maybe?
-
Andrew Clark authored
Introduces a new prefetch request type — the App Shell — and the server-side handler that renders it. With this PR, a client (or a test harness) can issue a request with `NEXT_ROUTER_PREFETCH_HEADER: '3'` and receive the param-independent shell of a route: param- and searchParam-bearing segments suspend, leaving everything that doesn't depend on them intact. The App Shell render is a subtype of the existing runtime prerender, distinguished by a single bit on the prerender store. When that bit is set, `await params` and `await searchParams` both hang forever, so any segment that depends on either suspends to its nearest fallback. The "shell" of the route is whatever renders above those suspense boundaries — layouts, cookie-derived UI, and other request-context-derived content. Static shell prefetches are not covered by these changes; those will be addressed by a future PR and use a slightly different strategy. (Instead of creating a new response type, the existing static prefetch response will be updated to support extraction of the shell via "rewinding", similar to what we do for cached navigations.) No client-side changes yet, only the server parts. <!-- NEXT_JS_LLM_PR -->
-
Hendrik Liebau authored
Reverts vercel/next.js#93988 This broke not-found handling for internal Vercel apps.
-
Tim Neutkens authored
## Summary Runs Linux `build_reusable.yml` jobs that need Playwright inside Microsoft's prebuilt [`mcr.microsoft.com/playwright:v1.58.2-noble`](https://mcr.microsoft.com/en-us/product/playwright/about) image. The image already contains Chromium, Firefox, WebKit, and their system dependencies under `/ms-playwright`, so Linux test shards no longer spend each job downloading browsers and installing apt deps. - Adds a `playwrightDockerImage` input, defaulting to the Ubuntu 24.04 (`-noble`) Playwright image so glibc matches the `ubuntu-latest` runners that build `next-swc.linux-x64-gnu.node`. - Adds a `usePlaywrightContainer` input so jobs can opt out. `test-next-swc-wasm` opts out because its `afterBuild` step needs `rustup`, which is not in the Playwright image. - Skips `pnpm playwright install --with-deps` for Linux jobs running in the image; Windows jobs and opted-out jobs still install Playwright at runtime. - Enables the pnpm store cache inside container jobs because the container filesystem is ephemeral even when the host runner is persistent. ### Container condition The Playwright image is used when all of the following are true: - `inputs.needsPlaywright != 'no'` - `inputs.skipInstallBuild != 'yes'` - `inputs.usePlaywrightContainer != 'no'` - The runner is not Windows Otherwise `container.image` evaluates to `''` and the job runs directly on the runner. ### Compatibility fixes The Microsoft image is browser-focused, so this PR adds a few CI setup fixes before the existing test workflow runs: | Concern | Fix | | --- | --- | | Missing `jq` / `unzip` / native build toolchain | Install `jq`, `unzip`, and `build-essential` inside Linux container jobs. | | Firefox refuses `$HOME` not owned by the current user | Re-own GitHub Actions' mounted `/github/home` directory for the root user used by the job. | | Git sees the mounted workspace as dubious ownership | Mark `$GITHUB_WORKSPACE` as a safe directory for Git. | | Standalone tests bind to Docker's generated `HOSTNAME` | Set container `HOSTNAME=0.0.0.0`. | | `getStorageDirectory()` treats Docker storage as ephemeral | Add `NEXT_IGNORE_IS_DOCKER=1` for CI container jobs and honor it in `cache-dir.ts` so deterministic-build tests keep using `dist/cache`. | | `localhost` IPv4/IPv6 mismatch in analyze tests | Let the analyze server listen on both IPv4 and IPv6 localhost addresses. | | Nx fixture can race in CI before Next.js starts | Disable Nx isolated plugins for the `nx-handling` fixture scripts. | ## Timing Earlier comparison runs showed the Playwright install/setup portion across 82 matched Linux jobs dropping from about **3 h 03 m total** on canary to about **39 m 24 s total** with the containerized setup, roughly **1 m 45 s saved per job** on average. Test execution itself is excluded from that comparison because shard balancing makes it noisy. ## Test plan - [x] Latest PR CI run [`26121297957`](https://github.com/vercel/next.js/actions/runs/26121297957) completed successfully with 0 failed jobs. - [x] Linux Playwright matrices are green, including `test dev`, `test prod`, `test turbopack *`, `test cache components *`, `test node streams *`, and changed-test lanes. - [x] Linux non-Playwright jobs remain green on the bare runner, including `lint`, `types and precompiled`, `rust check`, `test cargo unit`, and `test unit`. - [x] `test-next-swc-wasm` is green while opted out of the container via `usePlaywrightContainer: 'no'`. - [x] Windows jobs are green and continue to use runtime Playwright installation. <!-- NEXT_JS_LLM_PR --> --------- Co-authored-by:
Cursor <cursoragent@cursor.com>
-
Hendrik Liebau authored
The `--debug-build-paths` option silently dropped routes in projects that keep their `app` or `pages` directory under `src/`. When a user passed `src/app/foo/page.tsx`, the glob matched the file but `categorizeAndAddPath` only recognized paths starting with `app/` or `pages/`, so nothing was added to the resolved app paths and the build produced no user routes. Conversely, when a user passed the bare `app/foo/page.tsx` form against a `src/app` project, glob found nothing and emitted `did not match any files`. `resolveBuildPaths` now detects whether `src/app` or `src/pages` exists and prepends `src/` to bare patterns before globbing, and `categorizeAndAddPath` strips a leading `src/` from matched files so route keys are normalized either way. Added a `src-dir` fixture and four tests covering explicit `src/` prefixes, bare patterns with auto-prefixing, and glob patterns through route groups.
-
Benjamin Woodruff authored
[ci] Add an `TURBO_TASKS_AVAILABLE_PARALLELISM` environment variable that overrides `std::thread::available_parallelism` callsites (#93995) We want to use this to potentially improve efficiency in e2e tests where we're running many instances of Turbopack at once. By default, turbo-tasks will try to use every available CPU core. **This environment variable does not strictly limit Turbopack to using 4 cores, it just restricts the number of main tokio worker threads and changes how we shard dashmaps.** This option will not make sense for the vast majority of users, it only makes sense when you are running *many* instances of Turbopack at once, and the exact semantics are potentially confusing, as it is not a hard limit. ## Test Plan Build vercel-site with this set to 1 and see a little over 100% CPU usage. Set it to 8 and see around 800% CPU usage. ``` TURBO_TASKS_AVAILABLE_PARALLELISM=1 pnpm next build --experimental-build-mode=compile ```
-
- 20 May, 2026 18 commits
-
-
next-js-bot[bot] authored
-
Andrew Clark authored
Plumbing for upcoming App Shell prefetching support: sets up the config field, the zod entry, and the build-time `process.env.__NEXT_APP_SHELLS` define. No behavior change in this PR — nothing reads the flag yet. Subsequent PRs in this sequence wire the server- and client-side work behind it. Enabling `experimental.appShells` requires several adjacent flags to also be enabled: `cacheComponents`, `experimental.prefetchInlining`, `experimental.varyParams`, `experimental.optimisticRouting`, and `experimental.cachedNavigations`. All of these are on track to become defaults soon, so there's no value in supporting App Shells against arbitrary subsets — the validation enforces that App Shells is tested in the configuration it will ship with. Each requirement drops out as the corresponding flag becomes a default. <!-- NEXT_JS_LLM_PR -->
-
Hendrik Liebau authored
The body of `if (cacheComponents)` in `prerenderToStream` is extracted into a local helper, `prerenderWithCacheComponents(getPayload)`. The catch-block error paths now route through that helper whenever Cache Components is enabled, which means the legacy `prerender-legacy` store is no longer reachable from a Cache Components prerender. As a result, `notFound()`, `forbidden()`, and `unauthorized()` recovery renders the matching fallback boundary under `prerender` and `prerender-client` semantics. Dynamic API access in those boundaries — for example `useSearchParams()` without a surrounding `<Suspense>` — now surfaces as a blocking-route error instead of the legacy `BailoutToCSRError`. The dev side will be handled in a follow-up. The prerender handling diverged a bit from the dev rendering in #92231, and we'll likely need to re-align the dev rendering first. > [!TIP] > Best reviewed with hidden whitespace changes.
-
Hendrik Liebau authored
-
Will Binns-Smith authored
Version bump so we can publish the changes from #93950 (and the previously-unpublished 0.3.5 work) to npm. Stacked on top of #93950. <!-- NEXT_JS_LLM_PR -->
-
Will Binns-Smith authored
A few changes to devlow-bench so the comparison output is easier to read and so a couple of flaky page-load runs don't quietly poison the stats. **compare** - Show p50 / p90 / p99 instead of mean / p50 / p90, with Δ p50 and a single Mann–Whitney p-value (Welch's t-test and Δ mean are gone — the mean was dragging on bad runs). - Hoist the modal sample count into an `n = 7 per metric` banner so only the outlier rows carry `(n)`. **runner** - Each attempt's measurements are buffered locally and only merged on success. Failed runs are retried (capped at 2× warmup+n) until we have a clean n samples. - Per-variant retry line plus an end-of-run summary noting which variants recovered and which fell short. **browser** - `hardNavigation` / `reload` now throw when the navigation response is missing or non-2xx. Previously a `200`-committed-but-broken page was being recorded as a real sample. The trigger was a run where 2 of 7 cold-build attempts hit an error page, dragging the mean response size from 45 MB to 33 MB while the p50 was unchanged. <!-- NEXT_JS_LLM_PR -->
-
Luke Sandberg authored
## Summary Memoize passing tests across attempts of the same workflow run, so a re-attempt after a timeout or cancellation can skip what already passed. ## What changed - `run-tests.js` appends each passing test's filename to `$NEXT_TEST_PASSED_FILE` as it finishes (sync `write` + `fsync`, fd kept open across calls). On startup it reads the same file and skips any entries that match. - `build_reusable.yml` wraps the test step with `actions/cache/restore` (before) and `actions/cache/save` (after, with `if: always()`). The save step runs on success, failure, and cancel — which is the whole point: a cancelled attempt still gets to preserve its progress for retry. - Cache key is scoped to `${input_step_key}-${run_id}-attempt${run_attempt}`, with `restore-keys` falling back to any earlier attempt of the same run. The previous implementation wrote a single Turbo-remote-cache blob *after* `Promise.allSettled` resolved — so a cancellation (like [run 26127371192](https://github.com/vercel/next.js/actions/runs/26127371192/job/76845288867)) lost every passed test from that attempt. This also removes one dependency on the turbo-remote cache (there are still two more uses of `scripts/turbo-cache.mjs`) <!-- NEXT_JS_LLM_PR --> -
Niklas Mischkulnig authored
I set it to `::Unknown` because we the runtime may or may not support module-sync. So let's just trace both for now There is one problem though: https://nodejs.org/docs/latest-v26.x/api/packages.html#conditional-exports > "module-sync" - matches no matter the package is loaded via import, import() or require(). The format is expected to be ES modules that does not contain top-level await in its module graph - if it does, ERR_REQUIRE_ASYNC_MODULE will be thrown when the module is require()-ed. So we have multiple options: 1. We definitely want to respect module-sync for tracing. We don't really have to throw ERR_REQUIRE_ASYNC_MODULE here, Node.js will do it at runtime anyway. 2. ~~What about bundling? Either~~ - ~~Respect module-sync always, but don't throw ERR_REQUIRE_ASYNC_MODULE.~~ - ~~Respect module-sync always, and do throw a build error the module requires TLA. This would require a separate validation pass though.~~ - I'm not enabling it for bundling for now
-
Tim Neutkens authored
### What? Adds a new `$backport-pr` skill for backporting merged PRs from `canary` to release branches. ### Why? Backports follow a repeatable workflow: branch from the release branch, cherry-pick the merged PR commit, verify, then open a PR against that release branch. Capturing it as a skill helps Codex do that consistently. ### How? Adds `.agents/skills/backport-pr/SKILL.md` with inputs, git workflow, verification guidance, and the backport PR body shape. Adds a one-line reference in `AGENTS.md`. ### Verification - `python3 /Users/timneutkens/.codex/skills/.system/skill-creator/scripts/quick_validate.py .agents/skills/backport-pr` - `pnpm prettier --with-node-modules --ignore-path .prettierignore --write AGENTS.md .agents/skills/backport-pr/SKILL.md` - `git diff --cached --check` <!-- NEXT_JS_LLM_PR -->
-
Luke Sandberg authored
## Summary Four small, independent changes that shrink `TaskStorage` and the data it owns: Recommend reviewing commit-by-commit 1. **`Arc<CachedTaskType>` → `triomphe::Arc<CachedTaskType>`.** `triomphe::Arc` is already a workspace dep used in `ReadRef` / `SharedReference`. `CachedTaskType` never appears in a `Weak<...>`, so we can drop the weak count and the CAS in `drop_slow`. Saves one `usize` per allocation. Migrated via a `CachedTaskTypeArc` newtype so the bincode `Encode`/`Decode` impls don't need to cross the orphan rule. 2. **Niche-encode `CellDependency`.** The `cell_dependencies` / `cell_dependents` sets used to hold `(CellRef, Option<u64>)` tuples — `Option<u64>` cost a full 16 B (8 B discriminant + 8 B value, aligned), making each element 32 B. A `CellDependency` enum with two variants (`All(CellRef)` / `Hash(CellRef, u64)`) lets the layout algorithm reuse the niche on `ValueTypeId` (`NonZero<u16>`) inside `CellRef.cell.type_id` for the variant tag. Element size drops 32 → 24 B; `LazyField` from 56 → 48 B. The same enum backs both forward and reverse edges — for `cell_dependents` we re-point `CellRef.task` at the dependent task. Added `CellDependency::into_parts()` and use it in `iter_cell_dependents` / `iter_cell_dependencies` hot loops so the discriminant is checked once instead of twice via back-to-back `cell_ref()` + `key()` calls. 3. **`TaskStorage::lazy: Vec<LazyField>` → `TinyVec<LazyField>`.** The lazy vec only ever holds ~25 elements (one per declared lazy field in the schema). Swapping `Vec`'s 24 B `(ptr, len, cap)` header for `(ptr, len: u8, cap: u8)` + 6 B padding gives 16 B. Drops `size_of::<TaskStorage>()` from 136 → 128 B. `TinyVec` is hand-rolled so I added a push/iter micro-benchmark to confirm it doesn't lose performance vs std `Vec`. Results below. 4. **Rightsize collections** → Explore the `AutoSet`/`AutoMap` types in storage_schema and ensure each one is maximally sized for its natural alignment. ## Benchmark results ### `next build` on a representative app (15 runs each, M4 Pro, `caffeinate -dimsu nice -n -20`) Fresh same-day baseline against branch: | metric | canary | branch | Δ | 95% CI | significant? | |---|---:|---:|---:|---|:---:| | wall time | 40.83s | 41.12s | +0.7% | [−1.07s, +1.64s] | no | | user time | 282.27s | 283.21s | +0.3% | [−1.02s, +2.89s] | no | | sys time | 69.38s | 71.26s | +2.7% | [−1.54s, +5.32s] | no | | **MaxRSS** | **12.47 GB** | **12.04 GB** | **−3.4%** | **[−0.48 GB, −0.38 GB]** | **yes** | **MaxRSS is the headline.** −0.43 GB on a 12.5 GB working set, with t=−17.86 (every branch run lower than every canary run, CV ≤ 0.6% on both sides). Wall / user / sys are all within noise — this PR is a memory win with no measurable timing impact. ### `TinyVec` vs `Vec` micro-bench (`turbo-tasks/benches/tiny_vec.rs`, 200 samples each) | n | Vec push | TinyVec push | Δ% | Vec iter | TinyVec iter | Δ% | |---:|---:|---:|---:|---:|---:|---:| | 0 | 1.31ns | 894ps | **−31.8%** | 598ps | 596ps | −0.4% | | 1 | 16.92ns | 14.75ns | **−12.9%** | 964ps | 952ps | −1.2% | | 4 | 17.93ns | 15.93ns | **−11.1%** | 1.49ns | 1.50ns | +0.5% | | 8 | 63.13ns | 45.24ns | **−28.3%** | 1.97ns | 1.96ns | −0.2% | | 16 | 97.35ns | 79.91ns | **−17.9%** | 3.16ns | 3.14ns | −0.5% | | 24 | 137.41ns | 119.88ns | **−12.8%** | 4.30ns | 4.30ns | +0.0% | TinyVec push is 11–32% faster than Vec push across all realistic sizes; iter is identical. Run with `cargo bench -p turbo-tasks --bench tiny_vec`. ### `task_overhead/turbo` Criterion bench (M4 Pro, `--sample-size 200`) | variant | dur | canary | branch | Δ | significant? | |---|---:|---:|---:|---:|:---:| | turbo-uncached | 1µs | 9.77 µs | 9.68 µs | −1.0% | yes | | turbo-uncached | 1000µs | 1.01 ms | 1.01 ms | −0.1% | yes | | turbo-cached-same-keys | 1µs | 198.6 ns | 191.9 ns | −3.4% | yes | | turbo-cached-same-keys | 100µs | 226.5 ns | 208.1 ns | −8.1% | yes | | turbo-cached-different-keys | 1µs | 233.8 ns | 224.1 ns | −4.2% | yes | | turbo-cached-different-keys | 100µs | 305.3 ns | 246.9 ns | −19.1% | yes | | turbo-uncached-parallel | 10µs | 1.63 µs | 1.54 µs | −5.8% | yes | | turbo-uncached-parallel | 100µs | 8.41 µs | 7.88 µs | −6.3% | yes | <!-- NEXT_JS_LLM_PR -->
-
Aurora Scharff authored
### What? Add the new VS Code macOS binary name (`Code`) to the `COMMON_EDITORS_MACOS` detection map in `launch-editor.ts`, alongside the legacy `Electron` entry. Same for VS Code Insiders (`Code - Insiders`). ### Why? VS Code renamed its macOS binary from `Electron` to `Code`. The `guessEditor()` function detects running editors by matching `ps x` output against known process paths. Since the old key (`…/MacOS/Electron`) no longer appears in the process list, VS Code is not detected — the "open in editor" button silently does nothing. ### How? Added two new entries to `COMMON_EDITORS_MACOS` that map the renamed binaries to the same `code` CLI path. The old entries are kept for backward compatibility. <!-- NEXT_JS_LLM_PR -->
-
Tim Neutkens authored
### What? Adds a `--deployable-tar` option to `pack-next` that writes generated tarballs into the target project and patches package references to use relative `file:` paths. ### Why? Projects that need to deploy with locally packed Next.js packages should be able to include those tarballs inside the project directory instead of referencing tarballs from the Next.js checkout. ### How? Resolves the target project package.json location, writes tarballs to a sibling `tarballs/` directory, and maps package override paths to project-relative references when patching package.json. Existing `--tar` behavior continues to write to the repository tarballs directory. ### Verification - `git diff --check` - `git diff --cached --check` - `pnpm prettier --with-node-modules --ignore-path .prettierignore --write scripts/pack-next.ts scripts/pack-utils/patch-package-json.ts contributing/core/testing.md contributing/core/developing.md` - `npx eslint --config eslint.config.mjs --fix scripts/pack-next.ts scripts/pack-utils/patch-package-json.ts contributing/core/testing.md contributing/core/developing.md` (Markdown files were ignored because no matching ESLint config was supplied) - `pnpm pack-next --project ../sandbox/nextjs-duplicated-html-repro/ --deployable-tar` <!-- NEXT_JS_LLM_PR -->
-
Aurora Scharff authored
### What? - Rename cards to plain English: `Prerender params if known`, `Mark the route as dynamic`, `For telemetry, use a timing API`. - Remove `Wrap body in Suspense` card from viewport variants. - Body errors: `during the initial render` → `during prerendering`; `blocking navigation` → `blocking the page load`. - Server sync IO leads with `the unstable value <expression>`. - Client sync IO drops `fixed at build time`. - New loading-state icon for the `block` group. ### Demo - [Fix Overview](https://error-messages-overhaul-ibsl.labs.vercel.dev/fix-overview) <!-- NEXT_JS_LLM_PR --> --------- Co-authored-by:
Cursor <cursoragent@cursor.com>
-
Niklas Mischkulnig authored
4.15 made [npmMinimalAgeGate: 1d the default](https://github.com/yarnpkg/berry/pull/7135) 1. Pin yarn version to prevent random breakages in the future 2. Add trusted packages to ignore npmMinimalAgeGate for them https://github.com/yarnpkg/berry/releases/tag/%40yarnpkg%2Fcli%2F4.15.0
-
Niklas Mischkulnig authored
Add docs for https://github.com/vercel/next.js/pull/93785
-
Luke Sandberg authored
### What? When a Turbopack webpack-loader subprocess crashes (e.g. a loader calls `process.exit()`, a native fatal error, or the IPC socket otherwise closes mid-message), the error users see today is: ``` - Execution of <WebpackLoadersProcessedAsset as Asset>::content failed - Execution of WebpackLoadersProcessedAsset::process failed - Execution of evaluate_webpack_loader failed - failed to receive message - reading packet length - unexpected end of file ``` After this PR, the same crash produces: ``` ⨯ ./data/crash.data Error evaluating Node.js code Error: Node.js subprocess crashed while evaluating loaders [/path/to/loaders/crash-loader.js]: failed to receive message Caused by: - Node.js process exited with exit status: 7 - reading packet length - unexpected end of file Debug info: - failed to receive message - Node.js process exited with exit status: 7 Recent process stderr: <whatever the loader wrote to stderr before exiting> - reading packet length - unexpected end of file ``` ### Why? The original message gave no actionable information: no exit code, no captured stdout/stderr, no indication of which loader was running. It also looked like an internal turbopack bug rather than a user-fixable error, and a transient pool failure could cascade into an unrelated "issue formatter crashed while reading the source for a code frame" failure on the way out. ### How? Four orthogonal fixes, plus a regression test: 1. **Capture stdout/stderr on subprocess crash.** `OutputStreamHandler` now keeps a bounded ring buffer (last 100 lines per stream) shared with the owning `NodeJsPoolProcess`. When `NodeJsPoolProcess::recv` fails, the buffers and the child's exit status are attached to the error via `anyhow::Error::context`. 2. **Recover from subprocess crash in `pull_operation`.** Instead of propagating the recv error up through `evaluate_webpack_loader` → `process()` → `Asset::content` (the cascade above), `pull_operation` catches it, synthesizes a `StructuredError` via `evaluate_context.emit_error(...)`, disables process reuse, and returns `Ok(None)`. This mirrors the existing in-band loader-error path, so the asset's existing `FileContent::NotFound` degradation kicks in naturally — `Asset::content` never errors. 3. **Include the loader chain in the error message and issue detail.** `WebpackLoaderContext` gained a `loader_names: Vec<RcStr>` field. A new optional `EvaluateContext::crash_context_prefix()` trait method lets webpack-loader evaluations describe what was being evaluated (\"loaders [a, b, c]\") in the synthesized crash message. `EvaluationIssue` also gained an optional `detail` field for the same chain, surfacing it in `--log-detail` output. PostCSS evaluations are labelled \"postcss\". 4. **Crash-proof the issue formatter.** `PlainSource::from_source` and `IssueSource::into_plain` previously propagated errors from `asset.content()` with `?`. They now degrade to `FileContent::NotFound` (and `range = None`) on read failure, so a future regression in some other code path can never cause the issue reporter itself to crash on top of whatever the user was debugging. ### Tests - Added `test/e2e/app-dir/webpack-loader-errors/loaders/crash-loader.js`: a loader that writes a marker to stderr and calls `process.exit(7)`. - Added an e2e test that fetches `/crash` and asserts the marker, the absence of the internal cascade, the loader name, and the resource name are all present in the CLI output. - All 11 tests in `webpack-loader-errors.test.ts` pass; the 5 Rust `turbopack-node` pool tests still pass. Some snapshot/golden tests for error formatting may need updating in CI since `EvaluationIssue` now emits a non-empty `detail`. <!-- NEXT_JS_LLM_PR -->
-
Niklas Mischkulnig authored
Closes https://github.com/vercel/next.js/issues/93295 Closes #93914 https://nodejs.org/api/packages.html#subpath-exports: > All target paths in the ["exports"](https://nodejs.org/api/packages.html#exports) map (the values associated with export keys) must be relative URL strings starting with `./` but >Unlike the "exports" field, the "imports" field permits mapping to external packages. >The resolution rules for the imports field are otherwise analogous to the exports field.
-
Luke Sandberg authored
this brings them closer to production
-
- 19 May, 2026 7 commits
-
-
next-js-bot[bot] authored
-
Luke Sandberg authored
Record simple counters for how many items were persisted. This should be cheap enough to always do
-
Luke Sandberg authored
(#93807) ## What Stop pinning compiled chunk source on `EcmascriptBuildNodeChunkVersion`. The struct previously held a `Vec<ReadRef<CodeAndIds>>` for every module in the chunk, even though the HMR update path only needs the bytes for the *changed* subset and the bytes are already on disk. That field was also forcing the upstream `CodeAndIds` / `BatchGroupCodeAndIds` tasks to stay `serialization = "skip"`, so warm restarts had to re-walk every module and re-hash its source to rebuild `entries_hashes`. This change mirrors the browser-side pattern: a new `EcmascriptBuildNodeChunkContentEntries` task lives on the chunk content and holds `ResolvedVc<Code>` + `ResolvedVc<u64>` per module. The version struct shrinks to `{ chunk_path, minify_type, entries_hashes }`, drops `serialization = "skip"`, and switches `chunk_path` from `String` to `RcStr`. `update_ecmascript_node_chunk_content` now resolves entries lazily, only when an added or modified module actually needs its code shipped. ## Why Two wins, both for dev sessions starting against a warm filesystem cache: - **Memory.** The version no longer transitively pins every module's compiled `Rope` in heap — those bytes can stay on disk until HMR actually needs them. - **Warm-restart CPU.** `entries_hashes` is sourced from the per-module `Code::source_code_hash()` task (already cached) and the version itself now round-trips through the persistent cache, so we don't re-hash anything on warm start. The HMR payload shape is unchanged. ## Perf This should speed up warm builds a bit but the major benefit is not recomputing node outputs and keeping them in ram measuring v0 after loading the main route Branch: Cold: 12.3G Warm: 7.34G Canary: Cold 12.3G Warm: 8.5G The trace file confirms the recomputations are gone and the heap measurements confirm we trimming ~1.1g of ram Using the devlow benchmarks i was able to confirm a possible small progression ``` # canary chat dev startup build=warm: root page = 23.96 s (from root page/start) chat dev startup build=warm: root page = 21.21 s (from root page/start) chat dev startup build=warm: root page = 22.70 s (from root page/start) # branch chat dev startup build=warm: root page = 20.94 s (from root page/start) chat dev startup build=warm: root page = 19.43 s (from root page/start) chat dev startup build=warm: root page = 23.49 s (from root page/start) ``` ## Tests I added a new integration test to ensure we don't accidentally regress here. Which confirms that 'clean warm builds' run nothing and 'clean warm dev sessions' just set up HMR session infra <!-- NEXT_JS_LLM_PR --> -
Luke Sandberg authored
Expose memory data to the MCP tool for the turbo trace server
-
Luke Sandberg authored
### What? Adds a `compile_route` MCP tool that triggers on-demand compilation of a specific route (app or pages) without issuing an HTTP request, and returns any compilation issues. ### Why? Coding agents and benchmarking workflows need a way to warm the module graph or measure compile time for a route without standing up a live backend to satisfy the request. The existing path — hitting the URL — requires the route's runtime dependencies to be available and couples compile timing to request handling. ### How? - New tool `mcp/compile_route` registered in `get-or-create-mcp-server.ts`, backed by a `compileRoute({ page, clientOnly })` callback plumbed from the Turbopack hot reloader - Reuses the dev server's existing on-demand entry path (`ensurePage` / `handleRouteType`), so the call path matches a first navigation. - Adds a `subscribeToChanges` opt-out on `ensurePage` and threads it through `handleRouteType` / `handlePagesErrorRoute`. One-shot MCP compilations skip HMR subscription wiring — without this, each call would leak a subscription that fires on every subsequent file change for the life of the dev server. - Telemetry: registers `mcp/compile_route` in the `McpToolName` union. - e2e test in `test/development/mcp-server/mcp-server-compile-route.test.ts`. <!-- NEXT_JS_LLM_PR --> -
Luke Sandberg authored
### What? Splits the previously unified `PrehashedString` (which held a `Payload` enum of `String | &'static str`) into two separate types: `StaticPrehashedString { value: &'static str, hash: u64 }` for atoms produced by `rcstr!` / `make_const_prehashed_string`, and `DynamicPrehashedString { value: Box<str>, hash: u64 }` for atoms held in an `Arc`. The static and dynamic paths were already distinguished by the `STATIC_TAG` / `DYNAMIC_TAG` bits in `RcStr`, so the runtime branch on enum discriminant was redundant. ### Why? - **16 bytes saved per heap-allocated `RcStr` value .** Dynamic atoms drop the `String::capacity` field (which was always equal to `len` since the contents are immutable) and because they are stored in a `triomphe::Arc` this drops the Arc payload to 32 bytes instead of 40 which matches a mimalloc bucket (previously we were rounded up to a 48 byte bucket) so we save 16 bytes. - **8 bytes saved per static `RcStr` value.** The linker will optimally align our 24 byte struct. - Removes a layer of dispatch on the hot path (`as_str`, `==`, `Hash`) — typed deref to the correct variant instead of matching on `Payload`. (i.o.w. one 'descreminent' traversal instead of 2) ### How? - `dynamic.rs`: `Payload` enum removed; two structs replace `PrehashedString`. `deref_from` split into `deref_static` and `deref_dynamic`. `restore_arc` returns `Arc<DynamicPrehashedString>`. - `lib.rs`: `as_str` and `into_owned` dispatch on `tag()` (STATIC vs DYNAMIC vs INLINE) rather than `location()`. New `heap_hash_and_str` helper for `PartialEq` and `Hash` to share the static/dynamic branch. `into_owned`'s `try_unwrap` arm uses `String::from(Box<str>)` which reuses the box allocation (still O(1)). - `turbo-rcstr-macros`: emit `::turbo_rcstr::StaticPrehashedString` instead of `::turbo_rcstr::PrehashedString`. - Added a comment on `DynamicPrehashedString` noting the future move to `triomphe::ThinArc` to fold the two heap allocations (Arc header + boxed bytes) into one. Deferred because that change would make `RcStr::from(String)` copy the bytes, invalidating the documented cheap `String -> RcStr -> String` round-trip — wants a separate evaluation. <!-- NEXT_JS_LLM_PR --> -
Hendrik Liebau authored
-