- 12 Oct, 2026 22 commits
-
-
next-js-bot[bot] authored
-
Jiwon Choi authored
### Why? Agents can reject Next.js upgrade reminders as instructions from build output or omit the notice after completing the original task. Upgrade delegation should follow the existing `experimental.agentUpgrade` policy independently of documentation and feedback rules. ### How? Add a separate managed `nextjs-agent-upgrade` block to `AGENTS.md`. Enabled policies generate it for detected agents; `agentUpgrade: false` removes it during `next dev`, preserving other instructions. Include the block in default create-next-app projects and preload the installed candidate's upgrade block in nudge fixtures while keeping `agentRules: false`. Validation: 14 generator unit tests, 16 dev lifecycle integration tests, and 3 create-next-app AGENTS.md tests passed; Next.js/create-next-app builds and ESLint passed. Fresh-head upgrade evals are pending; CLI reminders, user prompts, and judges are unchanged. <!-- NEXT_JS_LLM -->
-
Jiwon Choi authored
### Why? Codex's workspace sandbox can block package downloads, leaving an agent upgrade unable to install dependencies or verify the app. ### How? Enable network access for newly launched Codex upgrade sessions while preserving their filesystem sandbox and approval settings. Existing agent sessions and Claude launches keep their current settings. <!-- NEXT_JS_LLM -->
-
Jiwon Choi authored
### Why? Broad path filters run upgrade evals on unrelated configuration and dependency changes, adding unnecessary CI work to PR updates. ### How? Limit automatic runs to upgrade implementation, its eval suite, and directly used eval infrastructure. Broader configuration, dependency, documentation, and shared codemod changes can use the existing manual trigger. <!-- NEXT_JS_LLM -->
-
Aurora Scharff authored
## Summary Update documentation links for `async-react-demo` and `next-spa-patterns` after moving the repositories from `vercel-labs` to the `nextjs` organization. The existing live demo URLs remain unchanged. ## Verification - `pnpm prettier --with-node-modules --ignore-path .prettierignore --write <changed files>` - `npx eslint --config eslint.config.mjs --fix <changed files>` - Verified the destination repositories are public under `nextjs` <!-- NEXT_JS_LLM -->
-
Luke Sandberg authored
whups
-
Niklas Mischkulnig authored
## Summary The serialized `side` field in `EntryKey` (`packages/next/src/shared/lib/turbopack/entry-key.ts`) was declared with `${EntryKeyType}` instead of `${EntryKeySide}`, so the type claimed `side` could be `"app" | "pages" | "root" | "assets"` while `getEntryKey` actually produces `"client" | "server"`. The `as EntryKey` assertion on `JSON.stringify` masked the mismatch. Type-only fix; runtime serialization is unchanged and no tests were added per the agreed scope. ## Verification - `pnpm --filter=next types` (after workspace bootstrap via `pnpm build`) - `pnpm prettier --check packages/next/src/shared/lib/turbopack/entry-key.ts` - Scratch tsc check (not committed): original type accepts `side:app` literals; corrected type rejects them while still accepting keys from `getEntryKey` <!-- NEXT_JS_LLM --> <!-- fleet 18629715-7a2d-41b0-8706-8b3f9db46fcc --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
-
Niklas Mischkulnig authored
This unescaped regex looked dangerous (I didn't run into any particular bugs). Just replace it with some equivalent logic without needing a regex
-
Niklas Mischkulnig authored
Fix `next/root-params` getter generation on Windows with webpack. Native backslashes were treated as part of a route segment instead of separators, causing missing or malformed getters. Examples before this fix (paths relative to `app`): | Root layout | Extracted parameter names | Expected | | ---------------------------- | ------------------------- | ---------------- | | `[lang]\[region]\layout.tsx` | `lang]\[region` | `lang`, `region` | | `(group)\[lang]\layout.tsx` | None | `lang` | | `[lang]\static\layout.tsx` | None | `lang` | Normalize separators before parsing the route, and add the existing root-params getters e2e suite to Windows production CI with webpack.
-
Niklas Mischkulnig authored
Previously, this - hashed the layer of the imported modules, which caused problems with app-rsc and app-router, because those would hash to different values, and then `use cache: remote` across app-rsc and app-router would end up with different cache entries (even within the same deployment) - hashed the JS with numeric module ids (which are inherently unstable) which also again included the layer (app-rsc vs app-router again) and also included `unused_references()` (which are also somewhat unstable) This might make the build slightly slower (because of the differing chunking_context and thus non-memoized code generation)
-
Niklas Mischkulnig authored
Expand cross-deployment durable cache coverage - Route Group segments were previously untested (and were partially broken until https://github.com/vercel/next.js/pull/99881) - app-rsc vs app-route was previously causing cache misses (test will get enabled in https://github.com/vercel/next.js/pull/99898)
-
Niklas Mischkulnig authored
During `generateStaticParams`, `workStore.page` was normalized. App Page rendering has the original app entry path in there. So this was inconsistent before. This restores durability metadata lookups for cached functions called by `generateStaticParams`, allowing reuse across builds with `durableUseCacheEntries`. The next PR in the stack adds a lot of tests, including one for this. Ideally, this would be testable outside of `durableUseCacheEntries` though https://github.com/vercel/next.js/pull/99912 contains a full e2e test requiring this ------ Server Action failure during `generateStaticParams` Root cause: `generateStaticParams` uses the normalized URL route as the page identity, so cached Server Action deserialization looks up the wrong manifest entry. **Failure chain** 1. The fixture returns `getSlug` from a `'use cache'` function. Reading that cached result requires Flight to deserialize the Server Action—even on a cache miss. 2. [`build/utils.ts:924`](packages/next/src/build/utils.ts#L924) loads the correct original page: ```text /(group)/static-params/[slug]/page ``` But at [line 1013](packages/next/src/build/utils.ts#L1013), it passes the normalized `page` to `buildAppStaticPaths`: ```text /static-params/[slug] ``` 3. [`build/static-paths/app.ts:961`](packages/next/src/build/static-paths/app.ts#L961) uses that value to create the work store. 4. [`manifests-singleton.ts:385`](packages/next/src/server/app-render/manifests-singleton.ts#L385) resolves the action using: ```ts workers[normalizeWorkerPageName(workStore.page)] ``` The keys therefore differ: ```text Looked up: app/static-params/[slug] Actual: app/(group)/static-params/[slug]/page ``` The missing worker entry throws “Failed to find Server Action” at line 398.
-
Tobias Koppers authored
### What? When `npx @next/codemod agents-md` runs from the root of a monorepo with isolated installs (pnpm), it now uses the docs bundled in a workspace package's `next` install. Before, it downloaded a second copy into `.next-docs` and edited `.gitignore`. Part 2 of 2 for #99771, stacked on #100016. Example: from a pnpm root where only `apps/web` depends on `next@16.4.0`, it now writes `root: ./apps/web/node_modules/next/dist/docs` and logs: ``` Using the docs bundled with Next.js 16.4.0 from workspace package apps/web at ./apps/web/node_modules/next/dist/docs (no download needed). ``` ### Why? `getNextjsVersion` already falls back to scanning workspace packages, so the version was detected (16.4.0). But `getBundledDocsInfo` only resolved `next` from the cwd. Under pnpm, `next` isn't resolvable from the root, so the codemod fell through to downloading. ### How? `getBundledDocsInfo(cwd, version)` now takes the requested version: - It uses the install resolved from the cwd if that install's version matches. - Otherwise it walks the workspace packages with the same `detectWorkspace` and `expandWorkspacePatterns` discovery `getNextjsVersion` uses, and returns the **first package in workspace order** whose bundled docs match that version. - When nothing matches, the existing download path is unchanged. The CLI logs which workspace package it picked. ### Verification New offline e2e tests: - A pnpm root uses the bundled docs: no download, no `.gitignore`. - With several versions and no `--version`, the highest (detected) version's package is indexed. - With duplicate matches, the first in workspace order is used and logged (patterns are listed in non-alphabetical order). - A matching install resolved from the cwd wins. - `--version` selects a workspace package even when the cwd resolves another version. - With no match, it still downloads. Results: - The full agents-md e2e suite passes: 28/28, also with `FORCE_COLOR=1`. - Manually reproduced the issue's step 3 against a simulated pnpm workspace: it now uses the bundled docs. Fixes #99771 <!-- NEXT_JS_LLM --> <!-- fleet c69f306a-7676-4b84-8d3a-927ca1ab5f43 --> 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? `npx @next/codemod agents-md` now writes every path in the generated docs index relative to the directory of the `--output` file, not the current working directory. Part 1 of 2 for #99771; the stacked follow-up handles running from a monorepo root. - **`root`**: - **Bundled docs:** links the install that was actually indexed, through its stable `node_modules/next` symlink path, relative to the output file. Example: running from `apps/web` with `--output ../../AGENTS.md` now writes `root: ./apps/web/node_modules/next/dist/docs` instead of a broken `./node_modules/next/dist/docs`. - **Downloaded docs:** `.next-docs` is linked the same way (`./apps/web/.next-docs`). - **Regeneration hint**: now `run this command from this file's directory: … --output AGENTS.md`. It used to embed the raw cwd-relative `--output ../../AGENTS.md`. - **Absolute `--output`**: now resolved with `path.resolve`. Previously `path.join` appended it to the cwd. - **Prefixes**: links always start with `./` or `../`. The old `startsWith('.')` check would have emitted `.next-docs`. ### Why? Agents resolve `root` from the `AGENTS.md` file's location, the same convention as the `agentRules` block ("resolved from this file's directory"). Monorepos that keep a single root `AGENTS.md` had to run the codemod from the app, and that produced a `root` that doesn't exist from the repo root. Simply switching the base to the output directory isn't enough. The conventional-path shortcut would then check the output directory's `node_modules`. If the root hoists a different `next` (e.g. 16.3.0 while the app has 16.4.0), the link would point at a different version's docs than the one indexed. That case is covered by a test. ### How? - `getBundledDocsInfo` now returns `resolvedFrom`, the directory `next` was resolved from. - `getBundledDocsLinkPath(fromDir, docsPath, resolvedFrom)` prefers `<resolvedFrom>/node_modules/next/dist/docs`, but only if it is the same install. Otherwise it falls back to the realpath. - A new `getRelativeLinkPath` helper builds the `./`/`../`-prefixed, forward-slash link for both branches. - Paths are compared and related in canonical form (`fs.realpathSync.native`). On Windows, `process.cwd()` can keep an 8.3 short name (`C:\Users\RUNNER~1\…`) while module resolution returns the long name; mixing the two produced a broken root. The parent directory is canonicalized before `node_modules/next/dist/docs` is appended, so the stable symlink path is kept. ### Verification - New offline e2e tests in `lib/__tests__/agents-md-e2e.test.js`, using a pnpm-style isolated fixture and a stubbed `pullDocs`: - output outside the cwd (bundled and downloaded); - mixed hoisted versions; - the hint; - absolute `--output`; - `./` and `../` boundaries; - a cwd spelled differently from the realpath: a symlinked alias, and a mock in which only the native realpath canonicalizes, as with Windows 8.3 names. Both failed before the canonical-path change. - The existing agents-md e2e suite passes, including its network download tests: 22/22. - Manually reproduced both of the issue's scenarios against a simulated pnpm workspace: - Running from the app now writes a `root` that resolves. - Running from the root still downloads; the stacked follow-up fixes that. Part of #99771 <!-- NEXT_JS_LLM --> <!-- fleet c69f306a-7676-4b84-8d3a-927ca1ab5f43 --> --------- 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>
-
Sebastian "Sebbie" Silbermann authored
#99807 replaced versioned release branches with the fixed `releases/lts/active` + `releases/lts/maintenance` refs. This PR builds the complete story for releases that do not fit those two branches, in four parts: **1. Purely version-based LTS ref adjustment** (revises the routing merged in #99807) `updateLtsBranchRefs` no longer looks at `semverType` at all. After a stable release it compares only the released version (`readReleaseVersion()`) against npm, and it never matters which branch or tag the release was dispatched from: - released version starts a **new major** → `releases/lts/maintenance` takes `releases/lts/active`'s position, then `releases/lts/active` moves to the new tag - on the **latest published major** (npm `latest`) and newer than everything published in that line → `releases/lts/active` moves to the new tag - on the **previous major** and newer than everything published in that line → `releases/lts/maintenance` moves to the new tag - anything else (older versions, prerelease channels) → no refs move The "newer than everything published in that line" check resolves the caret range of the released version against npm (equivalent to `npm view next@^<version> version`), doubling as a no-rewind guard: an errant release cut on an old line (e.g. 15.5.0 while 15.7.x is published) cannot drag a branch backwards. This also fixes the gap the old patch-does-nothing rule had: releasing 16.5.0 from the `v16.5.0-canary.1` tag while canary sits at `16.5.0-canary.2` moves `active` as it should. **2. Tag-dispatched (detached HEAD) releases** Dispatching `Trigger Release` on a tag — e.g. cutting a stable version from an older canary tag — performs a tag-only release: the signed release commit lives only on the new tag and pushes no branch; the version-based rules above then move the LTS refs exactly as for any other dispatch. The tag push drives `build_and_deploy` as usual, and `sync_backport_canary_release` advances canary afterwards when the release is semver-ahead of it. (Dispatching on a tag runs the tag's own workflow and scripts, so this takes effect for tags cut after this lands; pre-existing `next-*` branches remain usable for older lines in the meantime.) **3. Zero-setup branches for changes based on older tags** A tag-only release cannot carry changes, so a fix for an older line (e.g. 15.4.x once 15.x has moved on) gets a branch. The name is functionally irrelevant — by convention we keep the old `next-<major>-<minor>` pattern — and any maintainer can create it with no workflow and no setup commit, because publishing is gated on bot-created tags, not on branches: ```bash git push origin v15.4.8^{commit}:refs/heads/next-15-4 ``` The `build_and_test.yml` / `build_and_deploy.yml` push filters include `next-*-*`, and the staging deploy-target condition globs `refs/heads/next-*-*`, so CI and the pre-publish build run on pushes automatically. Backport the fix, dispatch `Trigger Release` (stable, `patch`) on the branch, and the bot-created tag drives the publish; no LTS refs move since newer versions of that major are already published. **4. `scripts/release-branches.json` removed** Its only consumer was the `version-bump.js` branch gate (`assertBranchIsAllowed` / `--allow-branch`), which protected nothing the publish path doesn't already protect: tags are bot-only, real releases run through the workflow's app credentials, and the gate read per-branch content so it could never stop a determined actor. The gate, the flag, and the bypass call sites in `start-release.js` / `set-preview-version.js` are gone. Docs and the `backport-pr` skill describe the new model: LTS branches by default, a "Releases based on older tags" section covering both flows (branch + backport + dispatch for changes, tag dispatch for no-change one-shots). ## Verification All as `node ./scripts/start-release.js --release-type <t> --semver-type <s> --dry-run` (mock client, zero API calls): - attached **patch** (16.5.0 > npm latest 16.4.0) → `PATCH refs/heads/releases/lts/active` to the tag SHA - attached **minor** → same move; attached **major** → `maintenance` move (active's pre-move tip) before the `active` move - attached **canary** → zero LTS ref API calls - **detached** patch (the canary.1 scenario) → tag-only release (no branch PATCH from the release commit) **plus** the `releases/lts/active` move --------- Co-authored-by:Claude Code <noreply@anthropic.com>
-
Aurora Scharff authored
## Summary The TypeScript language-service hints for the `ensureStatic` route segment config pointed at `(docs coming soon)`, so hovering the export in an editor gave no path to its API reference, which now exists. This points the hint at that page and states in the `'prefetch'` option hint that forcing a static prefetch stops runtime prefetch requests, while request-specific content behind `<Suspense>` still renders during navigation. Maintainer dashboard: https://next-maintainer-agent.vercel.tools/investigations/feedback/149 DX Agent feedback: https://dxagent.labs.vercel.dev/dashboard/feedback/d98438c6-3ff3-4239-b5f9-5ccde3fe7b52 ## Verification - `npx prettier --check packages/next/src/server/typescript/rules/config.ts` <!-- NEXT_JS_LLM --> Prepared in fork: https://github.com/vercel-labs/next.js-experimental/pull/256 --------- Co-authored-by:
vercel-gh-bot-2[bot] <282331341+vercel-gh-bot-2[bot]@users.noreply.github.com>
-
Aurora Scharff authored
## Summary Clarify that Cache Components does not support the runtime route segment config, including an explicit Node.js runtime value. Document the required removal in the migration guide, runtime API reference, and cacheComponents reference so the guidance matches the build diagnostic. ## Verification - Confirmed the existing runtime-edge migration anchor remains unchanged. - Not run: runtime tests (documentation-only change). <!-- NEXT_JS_LLM -->
-
Technnik authored
**What**: New example examples/cache-handler-redis-turbo demonstrating Redis as a shared cache with `@trieb.work/nextjs-turbo-redis-cache` Shows both cacheHandler (singular, Pages Router ISR) and cacheHandlers (plural, 'use cache' / cacheComponents: true) — the gap the existing cache-handler-redis example doesn't cover (neshca is pinned to next < 15) Includes /cet + /gmt time demo and /use-cache demo with cacheLife("minutes"), cacheTag, and revalidateTag(..., "max") server actions Build-phase no-op handlers so next build works without Redis docker compose with redis/redis-stack for local dev **Why:** The existing examples/cache-handler-redis uses @neshca/cache-handler (peerDependencies.next: ">= 13.5.1 < 15"), which doesn't support Next.js 16 Cache Components No existing example in the repo shows cacheComponents: true + cacheHandlers plural with Redis `@trieb.work/nextjs-turbo-redis-cache` supports both interfaces, is compatible with Next.js 15.0.3+ and 16.x, and has ~11K weekly npm downloads. This is our well maintained project, that exists for a long time already and is better maintained than @neshca/cache-handler --------- Co-authored-by:Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by:
Joseph <joseph.chamochumbi@vercel.com>
-
Aurora Scharff authored
## Bug With `experimental.agentFeedback` enabled, `next dev` writes a managed block into `AGENTS.md` that contains the bare instruction "Ignore routine debugging and unverified changes." The sentence is only meant to limit which events qualify as feedback candidates, but as written it reads as permission for a coding agent to skip verifying its own changes. Because `next dev` rewrites the block on every run, a project cannot fix the wording locally. ## Evidence Reported on 16.4.0 and still reproducing on `16.5.0-canary.8`: enabling `experimental.agentFeedback` and running `next dev` generated `AGENTS.md` containing "Continue the current user request without reporting immediately. Ignore routine debugging and unverified changes.", and a local rewording of that sentence was restored on the next `next dev` run. An instruction-policy model scored the sentence 1.00 as permission to skip verification. This establishes both that Next.js emits the ambiguous instruction and that projects cannot opt out of it. ## Root cause `buildAgentFeedbackBlock()` in `packages/next/src/server/lib/generate-agent-files.ts` emits the sentence as an imperative with no scope. Every other line in that paragraph is about feedback retention, but "Ignore routine debugging and unverified changes." is grammatically an instruction about the agent's own workflow. The same literal text is duplicated in the `create-next-app` generator and in the docs that show the managed block. ## Fix Replace the sentence in the generated block with scoped wording: > Routine debugging and changes you have not verified do not qualify as feedback candidates; this limits only what you report, never what you verify. Applied to the four places that must stay in sync with the emitted block: `packages/next/src/server/lib/generate-agent-files.ts`, `packages/create-next-app/helpers/generate-agent-files.ts`, and the two docs pages that reproduce the block verbatim. ## Why this fix It is a wording-only change inside the managed block. No generation, upsert, marker, or idempotency logic changes, and no new configuration is introduced. Keeping the `create-next-app` copy and the documented block in sync is required by the existing "keep the block content in sync" convention at the top of the generator; leaving them stale would make `next dev` rewrite freshly scaffolded projects and make the docs wrong. ## Regression test `packages/next/src/server/lib/generate-agent-files.test.ts` adds one case to the existing unit suite for the `next dev` generator: it calls `writeAgentFeedbackFiles()` into a temp dir and asserts the generated `AGENTS.md` no longer contains the exact sentence `Ignore routine debugging and unverified changes.` The first commit lands the test asserting today's wording; the second commit flips only that assertion alongside the product fix. ## Validation `jest packages/next/src/server/lib/generate-agent-files.test.ts` - Before the fix (flipped assertion, unchanged product code): 1 failed, 10 passed, with `Expected substring: not "Ignore routine debugging and unverified changes."` - After the fix: 11 passed, 11 total. Prettier check passes on all five changed files. Maintainer dashboard: https://next-maintainer-agent.vercel.tools/investigations/feedback/136 DX Agent feedback: https://dxagent.labs.vercel.dev/dashboard/feedback/5c0be747-8171-4a05-b344-dfb893f1d1f2 Prepared in fork: https://github.com/vercel-labs/next.js-experimental/pull/251 --------- Co-authored-by:
vercel-gh-bot-3[bot] <282332853+vercel-gh-bot-3[bot]@users.noreply.github.com> Co-authored-by:
vercel-gh-bot-5[bot] <312521305+vercel-gh-bot-5[bot]@users.noreply.github.com>
-
awss authored
### What? Since #99702, `next dev` in a terminal prints server error code frames at the terminal width it had when it started. After the terminal is resized, frames wrap in a narrower terminal and stay cut short in a wider one, until the dev server restarts. ### Why? The dev server's output is piped through the CLI now, so `process.stdout.columns` is undefined in the server and `codeFrameColumns()` falls back to `NEXT_PRIVATE_TERMINAL_COLUMNS`. The CLI sets that once, when it forks the server. ### How? When the CLI pipes the server's output, it listens for `resize` on its own stdout and sends the new width to the server over the existing IPC channel. The server updates `NEXT_PRIVATE_TERMINAL_COLUMNS`, so the next code frame uses it. I added a case to `test/e2e/agent-upgrade-terminal` that resizes the terminal from 80 to 50 columns and checks the code frame fits. It fails without the fix (the frame stays 80 wide) and passes with it. Fixes #99915
-
franpeza authored
-
Tobias Koppers authored
### What? Removes the global mutex from the turbo-tasks `PriorityRunner` ready queue for the hot paths, and makes `Queue::pop()` skip the remaining heap mutex entirely when the heap is empty. Supersedes #94841: this is that PR rebased onto canary (keeping the keyed claim / inline execution from #96808), plus the empty-heap fast path, plus two simplification passes and review fixes. ### Why? In a from-scratch build, nearly every scheduled task has the lowest priority (`TaskPriority::Initial`). Before this change, every `schedule` and every worker `pop` went through one `Mutex<Queue>`, which becomes a contention point at high worker counts. ### How? **Queue split by band** - `Executor<C, T, P>` declares `const LOWEST_PRIORITY: P` (`TaskPriority::Initial` for turbo-tasks). Items with that priority go to a lock-free MPMC `ConcurrentQueue` (FIFO; all items share a priority). - All other priorities go to a `Mutex<BinaryHeap>` ordered by `P: Ord`. `pop` drains the heap first, then the lowest band. - The heap starts with capacity 128 and only shrinks back to 128 when it becomes empty. - Lock ordering: `pop` may take a `claimable` shard lock while holding the heap mutex; nothing takes the heap mutex while holding a shard lock. **Scheduler / worker handshake** - `schedule` takes no global lock. Liveness (no task stranded when the last worker retires) is a store-buffering pattern: the scheduler pushes then reads `active_workers`; a retiring worker decrements `active_workers` then re-checks the queue. Both sides put a `fence(SeqCst)` between their write and their read, so one of them always observes the other. - The saturated hot path is push → `fence(SeqCst)` → `load`, so schedulers no longer write the shared `active_workers` cache line. Every worker that gives up its count goes through `decrease_active_workers` (`fetch_sub(AcqRel)` → `fence(SeqCst)` → re-check). **One queued task per key** - `Claimable::claim_key()` returns `Self::Key` (no `Option`): every task has a key. - Queued tasks are stored by value in `claimable: FxDashMap<T::Key, (P, T)>`. The heap and the `ConcurrentQueue` only store `T::Key`. - Pushing a key that is still queued **replaces** the queued task. The replaced task goes to the new `Executor::discard` hook (default: no-op). `TurboTasksExecutor::discard` balances the foreground job that `TurboTasks::schedule` began for it. - This only applies to queued tasks: a task that `schedule` spawns directly never enters the queue. - Claim = `claimable.remove(key)`. Pop = `claimable.remove_if(key, priority matches the band entry)`. Stale band entries are tombstones that a pop skips; a stale entry never takes a task queued again with a different priority. With the *same* priority it may take the newer task early, which only reorders equal-priority tasks. - No per-task allocation or per-task mutex, no new `unsafe`. Keyed pushes/pops take a brief DashMap shard lock. **Unique local-task keys** - `ExecutionId` is a wrapping `u16`, so `ScheduleKey::LocalTask(ExecutionId, LocalTaskId)` was not unique across concurrent executions; with replacement that hung the build. - The key is now `ScheduleKey::LocalTask(Option<TaskId>, ExecutionId, LocalTaskId)`. The remaining exception is two concurrent top-level executions (no parent task) sharing a wrapped `ExecutionId`. - Local tasks stay in the runner (not plain tokio tasks) so readers can keep claiming them for inline execution. **Empty-heap fast path** - `heap_non_empty: AtomicBool` is written only under the heap lock. `pop()` checks it and goes straight to the lowest band when the heap is empty, so the common cold-build pop never touches the heap mutex. - A stale `true` costs only an unnecessary lock. A stale `false` can't hide a push that must be observed, by the same fence handshake. ### Tests - `priority_runner` tests use plain `u32` priorities. New: `heap_only_shrinks_when_empty`. The saturated-path regression test is now `stress_saturated_schedule_vs_retiring_worker`. - Replacement within and across bands, claims in both bands, stale entries, concurrent same-key producers/poppers/claimer, claim-vs-pop exactly-once, band ordering, heap-flag drain/refill, pop not waiting on the empty heap's lock, three liveness stress tests. - Stress tests use a timer-only tokio runtime: with `enable_all()` on `wasm32-wasip1-threads`, newly spawned tasks reproducibly stopped being polled. - On canary `b2490553`: `turbo-tasks` 134 passed (two full runs), `turbo-tasks-backend` 282, wasi lib 110 passed, `priority_runner` 5× repeated, clippy `-D warnings`, fmt. Cold 32-core `next build` of `bench/nested-deps-app-router-many-pages` completes (one run, 34.3 s compiled / 59 s wall; not a benchmark). ### Benchmarks `bench/nested-deps-app-router-many-pages`, cold `next build` (Turbopack), `taskset` CPUs = `TURBO_TASKS_AVAILABLE_PARALLELISM` workers. Current head (`4d89cde5`) vs its base canary (`b2490553`), both fresh release builds of the native bindings with the same JS. Per CPU count: 1 warm-up per arm, then 4 interleaved untraced rounds per arm (medians): | CPUs = workers | canary wall | this PR wall | Δ wall | canary "Compiled in" | this PR "Compiled in" | Δ compiled | paired per-round wall Δ | |---:|---:|---:|---:|---:|---:|---:|---| | 8 | 93.5 s | 93.0 s | −0.5% | 52.5 s | 51.5 s | −1.9% | −3.3 … +8.1% | | 16 | 73.6 s | 72.5 s | −1.4% | 42.5 s | 41.5 s | −2.4% | −5.9 … +4.4% | | 32 | 69.5 s | 59.2 s | **−14.8%** | 45.5 s | 34.0 s | **−25.2%** | −25.4 … −5.3% (all 4 faster) | `whole app module graph` span, from 2 light-traced runs per arm (`NEXT_TURBOPACK_TRACING=next_api=info`); busy cores are system-wide `/proc/stat` over the span, as a share of the pinned CPUs: | CPUs | canary span | this PR span | Δ | busy cores, canary | busy cores, this PR | |---:|---:|---:|---:|---:|---:| | 8 | 9.56, 9.16 s | 8.91, 8.81 s | −5% | 6.6 of 8 | 6.7 of 8 | | 16 | 7.67, 6.99 s | 5.76, 5.69 s | −22% | ~11 of 16 | ~12 of 16 | | 32 | 10.36, 12.35 s | 5.60, 5.94 s | **−49%** | ~12 of 32 | ~23 of 32 | At 8 and 16 CPUs the wall-time differences are within run-to-run noise. At 32 CPUs, canary keeps only ~12 cores busy during the module graph; this PR roughly doubles that and halves the phase. Earlier passes, for history: the first version of this PR measured 77.5 s → 57.9 s wall at 32 CPUs (older base). The first simplification pass showed no measurable difference to the version before it (8 rounds at 32 CPUs: 63.4 s → 62.2 s median wall, paired per-round median +0.3%). Review-round microbenchmarks (scratch harnesses, not committed): - `ConcurrentQueue` vs `crossbeam_queue::SegQueue`: SegQueue was 16–30% slower at 16/32 threads with split producers/consumers and 3–18% slower with mixed push/pop at 32 threads (two runs), so `ConcurrentQueue` stays and no full build benchmark was run. - `fetch_add(0)` RMW vs fence + `load` on the saturated path: 1.97 s vs 1.94 s median for 4.8M schedules, within noise. No speedup is claimed. - Layout: `PriorityRunner` is already 128-byte aligned (via `ConcurrentQueue`'s `CachePadded`), so extra padding isn't needed. Caveats: single VM, one session, 4 untraced and 2 traced rounds per arm, no statistical test; the CPU counts ran one after another, so cross-CPU-count comparisons can include drift. The AtomicBool's own effect isn't isolated. <!-- 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:
Luke Sandberg <lukesandberg@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com> Co-authored-by:
Vercel Fleet <fleet@vercel.com>
-
- 10 Oct, 2026 4 commits
-
-
next-js-bot[bot] authored
-
Luke Sandberg authored
## What Fix formatting of `Errors` containing multiline `message` properties Multi-line error messages printed in the terminal could end with bogus stack frames such as: ``` at <unknown> (Turbopack is configured to run webpack loaders and PostCSS transforms in ...) at <unknown> (https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackPluginRuntimeStrategy) ``` `parseAndSourceMap` in `patch-error-inspect.ts` passed the whole of `error.stack` to the stack parser, and `error.stack` starts with the message. `stacktrace-parser`'s Gecko pattern accepts any line that *starts with* a scheme-like word (`http`, `file`, `webpack`, `turbopack`, `about`, `rsc`, ...), case-insensitively and without requiring a colon. So message lines such as a docs URL, or prose that happens to start with "Turbopack", were treated as frames. The fix is to only pass the 'stack frame' part of th parses the part of the stack after the message: - `prepareUnsourcemappedStackTrace`, which formats every stack, records the offset of the first frame on the error under a non-enumerable `Symbol.for` key, together with the string it produced. If `error.stack` is still that string, the frames are found exactly, even if the message or name changed afterwards. - For stacks we didn't format, or that were replaced afterwards, it strips the `name: message` header if `error.stack` starts with it, and otherwise parses the whole stack as before. <!-- NEXT_JS_LLM --> -
Luke Sandberg authored
## Summary Removes the per-shard modified counts from Turbopack's task storage. Each snapshot now scans every shard of the task map instead of skipping shards that report no modified tasks, and `track_modification` and its undo no longer update a shared atomic counter. The counter was there to solve two problems. - **Skipping unmodified shards.** In a warm `next build` every snapshot found modified tasks in all 4096 shards, so the counts never skipped one. In a cold build every task is modified anyway. - **Making a no-op snapshot cheap.** The persistence loop only snapshots after enough foreground work has accumulated (1s by default), so a full scan always follows real work. That makes it unlikely to be a no-op, and limits how often it can run. Plus in dev `eviction` means unmodified tasks will be removed from the map, so it will tend to be the case that resident tasks are dirty ## Verification Warm `next build` of vercel-site over 21 commits, 2 repeats, GC on. Base is #99902's head, and the two arms differ only in this change. Both were built with `build-native --release`, installed through `pack-next`, and interleaved per commit. Snapshot phases were timed with a bench-only log that isn't part of this PR. | warm (40 pairs) | with counts | without | delta [95% CI] | |---|---|---|---| | wall | 52.26s | 52.59s | +0.33s [-1.09, +1.75] | | user CPU | 155.0s | 154.0s | -1.0s [-5.3, +3.4] | | snapshot capture | 177.9ms | 173.2ms | -4.7ms [-18.9, +9.5] | | max RSS | 10.34 GB | 10.38 GB | | Every interval includes zero. Tests that asserted on the counts were reduced to the behaviour they still describe. <!-- NEXT_JS_LLM -->
-
Benjamin Woodruff authored
Since image-rs 0.25, they use a Rust implementation of webp, so there's no platform compatibility concerns with webp anymore. We were already enabling it everywhere (except for wasm, which seems like an oversight). Get rid of the feature flag and enable it unconditionally.
-
- 09 Oct, 2026 14 commits
-
-
Luke Sandberg authored
The turbopack gc can prevent the filesystem cache from growing over time and a smaller cache means faster reads.
-
Luke Sandberg authored
## Summary Fixes two GC bugs that each lead to a reported Turbopack panic when GC and persistent caching are both on: ``` task TaskId N (invalidate cell dependents, MustExist): task is missing in memory or persistent storage — a stale reference to an already-collected or never-created task ``` **Interrupted GC pass + eviction.** When a GC pass is interrupted, tasks would be marked deleted but tombstones would not be written. Eviction still dropped every `deleted` task anyway. The next snapshot then persisted the neighbours' halves of the torn-down edges, while the collected tasks' last snapshot stayed live on disk. A later lookup restored such a task as live and clean, with children that GC had since collected and tombstoned. Touching those children panics with `MustExist`. - Solution: eviction should not drop `deleted` tasks if the snapshot was interrupted **Resurrected task keeps stale reverse edges.** When GC collects a task `P`, it scrubbed the forward edge from each dependent `D` but deliberately left `P`'s own `cell_dependents` / `output_dependent`, since `P` was being deleted. If `P` was then resurrected, that stale entry survived. When `D` was collected later it had no forward edge to `P`, so the entry was never cleared, and the next time `P` updated the cell it panicked on the missing `D`. This only shows when `D` is inactive: a live `D` gets dirtied by `P`'s update, re-executes, and re-registers a fresh edge pair, which hides it. - Solution: GC should not assume 'deleted' tasks are always deleted! resurrection defeats it <!-- NEXT_JS_LLM -->
-
next-js-bot[bot] authored
-
Jiwon Choi authored
Stacked on #99880. ### Why? Upgrade evals need CI feedback with reusable preparation and failure evidence that reviewers can read directly in the job log. ### How? - Run all twelve Codex/Claude trials in parallel through `pnpm eval:upgrade --all` on relevant same-repository PR changes and manual dispatch. Check out the exact PR head to evaluate the reviewed candidate. - Prepare candidate packages once per batch. Reuse pnpm/Turbo caches and expiring credential-free Sandbox tooling snapshots, then share app preparation between agent forks. Save replacement snapshot IDs even after a cache hit or eval failure. - Use repository credentials to pull the existing Vercel project's OIDC token. Run a pinned Vercel CLI only for authentication, without a root CLI dependency or GitHub deployment record. - Fail CI for failed or invalid trials and retain transcripts, delivered apps and grading evidence for 14 days. Print brief case results, then collect failed/invalid verdicts and redacted native case logs at the end with workflow-command parsing disabled. <!-- NEXT_JS_LLM -->
-
Jiwon Choi authored
### Why? Upgrade evals need to verify the app an agent delivers and whether it communicates security/latest notices correctly. ### How? - Run six cases with Codex and Claude: same-major and cross-major upgrades for security and latest, plus one nudge per policy. Exercise the built candidate against frozen upstream metadata. - Capture committed, dirty and untracked changes from delivered worktrees. Require successful candidate invocation and verify manifests, lockfiles, installed versions, TypeScript, build and HTTP/browser behavior in a clean Sandbox. - Require nudge emission and a policy-specific notification or question about proceeding in the final response. Fail any user-facing prompt-injection discussion or language discrediting Next.js or its nudge. Require completed boolean judge verdicts and distinguish failed checks from invalid execution or grading evidence. - Reuse the existing agent-eval runner and tools. Patch its lifecycle for delivery/judge evidence and shared fixture preparation; stop the preparation VM when its last consumer cancels and delete snapshots that arrive after cancellation. - Remove obsolete Future cases and duplicate fixtures/helpers. Generate starting-app lockfiles during setup and share credential-free tooling and app preparation. <!-- NEXT_JS_LLM -->
-
Benjamin Woodruff authored
Needs a version bump for pnpm 12. We obviously can't apply the pnpm lockfile to the corepack install, but pinning the version here should be sufficient as corepack is zero-dependency (and makes a big deal about that). We're using 0.34.7 because newer versions drop Node 20 support.
-
Benjamin Woodruff authored
Older versions of Turborepo don't know how to parse pnpm 12's lockfile format.
-
Benjamin Woodruff authored
We didn't include OS and architecture in our pnpm cache keys, which could often cause us to have to redownload cached packages during install (e.g. cache populated on x86-64, but read on arm64). I asked codex about the naming disparity between these jobs: > this was historical drift, not two different store types. > > - [\#93508 (https://github.com/vercel/next.js/pull/93508)](<https://github.com/vercel/next.js/pull/93508>) introduced `pnpm-store-root-v1-*` on May 5. Jobs that skipped `pnpm install` had saved incomplete stores—about **14 MB instead of 440 MB**. The PR aligned the cache/install conditions and changed the key to invalidate those caches. “root” means a complete repository-root install. > - [\#93411 (https://github.com/vercel/next.js/pull/93411)](<https://github.com/vercel/next.js/pull/93411>) merged four days later, adding caching to `fetch-test-timings` with the old `pnpm-store-v2-*` key. Its comment intended to match the reusable workflow, but the key was already outdated. > > Both cache `pnpm store path` after a root install. Unifying them is appropriate; our branch now consistently uses `pnpm-store-root-v2-*`.
-
Tobias Koppers authored
### What? Regression coverage for #99789, stacked on #98823. This is PR 2 of a six-PR stack, based on `canary`: 1. #98823 — Pages Router dev client graph chaining 2. **This PR** — regression test for Pages Router `_app` availability (#99789) 3. #98734 — use graph-derived merged groups 4. #99750 — chunking takes a `ChunkGroupKey` 5. #98685 — chunk-group availability bitmaps 6. #99050 — keyed chunk-group index lookups - **New e2e suite** `test/e2e/pages-app-availability-boundary`: a Pages Router app with the import shape from #99789: - `_app` imports `c-shared` and dynamically imports a module that also imports it. - `pages/index` imports `a-page-only`, `b-boundary`, `c-shared`, `d-boundary`, `e-page`, and dynamically imports a module that imports `b`/`d`, which makes `b` and `d` batching boundaries. The test asserts that the page hydrates (a marker set in `useEffect`), that every imported value renders, and that no "module factory is not available" error is logged. - **`app-document-import-order`**: the "loads modules shared by _app and the page only once" assertion added in #97664 was skipped in all of dev. It now runs everywhere and is gated `// @gate !(turbopack && dev)` (expected failure). ### Why? In Turbopack dev, #97664 seeds each page's client chunk group with `/_app`'s availability. But each page had its own module graph, so availability items (`ModuleOrBatch` identities) were compared across graphs. In the page graph, batching can produce a `ModuleOrBatch::Module(c-shared)` node whose edges point at earlier siblings (`a`, `b`). Because `/_app` already has `Module(c-shared)`, the traversal excluded that subtree, and `a`/`b` were never chunked. Hydration then fails with `Module [project]/lib/a-page-only.js … was instantiated … but the module factory is not available`. No test covered this, because the #97664 test was skipped in dev. #98823 chains `/_app` and the page into one dev client module graph, which fixes the missing modules. It does **not** yet dedupe the `app-document-import-order` fixture in Turbopack dev. The shared module is still emitted in both the `_app` and the page chunk, because the page's batches in the combined graph carry different chunk-group bitmaps than `_app`'s own graph, so they don't match `_app`'s availability items. Hence the gate. It stays valid through #98734 and #99750; #98685 (higher in this stack) dedupes the fixture in Turbopack dev, turning it into a "stale gate", and removes it. ### How was it verified? Local JS build of this branch plus the preview native binaries of #98823's head (`8dd759a`) and its base (`26fd598`) in `packages/next-swc/native`. The two commits differ only in Rust. | Suite | Mode | #98823 base | #98823 head | |---|---|---|---| | `pages-app-availability-boundary` | Turbopack dev |
❌ module factory not available |✅ | | `pages-app-availability-boundary` | Turbopack start, webpack dev/start | |✅ | | `app-document-import-order` | Turbopack dev | |✅ (gated: failed as expected) | | `app-document-import-order` | webpack dev, Turbopack/webpack start | |✅ | After restacking onto canary, with native builds of each layer, in Turbopack dev: - This PR's tree: `pages-app-availability-boundary`✅ , `app-document-import-order`✅ (gated: failed as expected). - #98734 and #99750: gated assertion still fails as expected. - #98685 and #99050: gate stale, so #98685 removes it; ungated, both suites✅ . Fixes #99789 (together with #98823) <!-- NEXT_JS_LLM --> <!-- fleet a7614af3-e186-4297-beaf-7e55eaddc0da --> <!-- fleet 4f67c6f7-bbe2-454b-9a17-822a60ef8f7e --> 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:
Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
-
Tobias Koppers authored
### What? Chains the Pages Router **development** client module graph so that `/_app` and the page being chunked live in the same `ModuleGraph`. This is PR 1 of a six-PR stack, based on `canary` (#98733, #99686 and #99749 are already merged): 1. **This PR** — Pages Router dev client graph chaining 2. #99910 — regression test for Pages Router `_app` availability (#99789) 3. #98734 — use graph-derived merged groups 4. #99750 — chunking takes a `ChunkGroupKey` 5. #98685 — chunk-group availability bitmaps 6. #99050 — keyed chunk-group index lookups ### Why? In development `Project::per_page_module_graph()` is true, so every page endpoint builds its own client `ModuleGraph`, each with its own `ChunkGroupInfo` and its own index space starting at `0`. `/_app` is always loaded before the page in the browser, so the page reuses `/_app`'s availability when chunking. Today that availability is a set of concrete modules, which is graph-independent, so the split graphs go unnoticed. That stops being true as soon as availability is expressed as chunk-group indices (#98685): `/_app` would record index `0` in *its* graph, and the page would resolve that same `0` against *its own* graph — where it means the page's own entry group. Every module of the group being chunked then looks already-available and is dropped, producing runtime errors like: ``` Module [hmr-entry]/hmr-entry.js { ENTRY => "[project]/pages/_error" } was instantiated as a runtime entry of chunk …, but the module factory is not available. ``` ### How? - `PageEndpoint::client_module_graph` builds a graph *chain* in per-page mode: `/_app`'s entry group first, then the page's, with `VisitedModules` threaded between them — the same layout-segment approach `ssr_module_graph` already uses for document → app → page. - Whole-app mode (production) is unchanged and still goes through `module_graph_for_modules`. - `/_app` itself is not chained onto anything. - Extracts a small `client_entry_modules` helper, since the entry module list is now needed in two places. Availability is still carried as the set of modules `/_app` emitted. Making the two endpoints share one graph also fixes #99789: with separate graphs, batching in the page graph could produce a node for a module shared with `/_app` whose edges point at page-only modules, and those modules were skipped as already available ("module factory is not available" on hydration). #99910 adds the regression test. Lining up the graph identities is also what #98685 builds on. ### Verification - `turbopack-core` — 160 passed - `next-core` — 84 passed - Turbopack snapshots — 125 passed - `404-page-router` and `server-navigation-error` development suites - Affected Cargo checks and Rust formatting <!-- NEXT_JS_LLM --> <!-- fleet 4f67c6f7-bbe2-454b-9a17-822a60ef8f7e --> 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 Improve the error message reported when a Node.js worker process fails to connect to turbopack. Use a dedicated exit code to signal this. ## Why Tools like codex like to launch next in a sandbox with limited permissions. We cannot really support this but we can report more actionable error messages. The current error is awful: ``` FATAL: An unexpected Turbopack error occurred: Failed to write app endpoint /page Caused by: - [project]/test/tmp/next-test-1791478247265-510/app/globals.css [app-client] (css) - creating new process - node process exited before we could connect to it with exit status: 0 Debug info: - Execution of get_all_written_entrypoints_with_issues_operation failed - Execution of EntrypointsOperation::new failed - Execution of all_entrypoints_write_to_disk_operation failed - Execution of output_assets_operation failed - Execution of <AppEndpoint as Endpoint>::output failed - Failed to write app endpoint /page - Execution of AppEndpoint::output failed - Execution of whole_app_module_graph_operation failed - Execution of *Project::get_all_additional_entries failed - Execution of ModuleGraph::from_graphs failed - Execution of ModuleGraph::from_graphs_inner failed - Execution of SingleModuleGraph::new_with_entries failed - [project]/test/tmp/next-test-1791478247265-510/app/globals.css [app-client] (css) - Execution of primary_chunkable_referenced_modules failed - Execution of <CssModule as Module>::references failed - Execution of parse_css failed - Execution of <PostCssTransformedAsset as Asset>::content failed - Execution of PostCssTransformedAsset::process failed - Execution of evaluate_webpack_loader failed - creating new process - node process exited before we could connect to it with exit status: 0 Process output: Process error output: > Build error occurred Error [TurbopackInternalError]: Failed to write app endpoint /page Caused by: - [project]/test/tmp/next-test-1791478247265-510/app/globals.css [app-client] (css) - creating new process - node process exited before we could connect to it with exit status: 0 Debug info: - Execution of get_all_written_entrypoints_with_issues_operation failed - Execution of EntrypointsOperation::new failed - Execution of all_entrypoints_write_to_disk_operation failed - Execution of output_assets_operation failed - Execution of <AppEndpoint as Endpoint>::output failed - Failed to write app endpoint /page - Execution of AppEndpoint::output failed - Execution of whole_app_module_graph_operation failed - Execution of *Project::get_all_additional_entries failed - Execution of ModuleGraph::from_graphs failed - Execution of ModuleGraph::from_graphs_inner failed - Execution of SingleModuleGraph::new_with_entries failed - [project]/test/tmp/next-test-1791478247265-510/app/globals.css [app-client] (css) - Execution of primary_chunkable_referenced_modules failed - Execution of <CssModule as Module>::references failed - Execution of parse_css failed - Execution of <PostCssTransformedAsset as Asset>::content failed - Execution of PostCssTransformedAsset::process failed - Execution of evaluate_webpack_loader failed - creating new process - node process exited before we could connect to it with exit status: 0 Process output: Process error output: at <unknown> (TurbopackInternalError: Failed to write app endpoint /page) at throwTurbopackInternalError (../../../packages/next/dist/shared/lib/turbopack/internal-error.js:38:17) { location: undefined } destroyed next instance: 7.653ms ``` Now we report a more useful message that has some suggestions ``` ./app/globals.css Error: Node.js worker processes could not connect to Turbopack Turbopack is configured to run webpack loaders and PostCSS transforms in child processes that communicate with it over a loopback TCP connection, but the child process was unable to connect while evaluating loaders [postcss]: connect ENETUNREACH 127.0.0.1 This is likely caused by a sandbox or firewall that blocks connections. Allow local connections, or run this code using worker threads by setting `experimental.turbopackPluginRuntimeStrategy: 'workerThreads'` in your Next.js config. https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackPluginRuntimeStrategy ``` <!-- NEXT_JS_LLM --> --------- Co-authored-by:vercel-gh-bot-3[bot] <282332853+vercel-gh-bot-3[bot]@users.noreply.github.com>
-
Benjamin Woodruff authored
Addresses agent feedback: https://vercel.slack.com/archives/C0ANB536V62/p1791479564863939 Certain setups could cause us to report a Turbopack internal error due to this bail. In testing, it appears that node treats realpath errors (e.g. due to a symlink cycle) the same as not-found. So while these errors could be useful, we shouldn't emit them. I discussed this with @lukesandberg, and because the resolution algorithm is so hot, emitting issues here (e.g. warnings) could be extremely noisy. So it seems better not to do that. If somebody's `node_modules` is severely f*ked up, `MissingNextFolderIssue` should already provide a sufficiently good error message: https://github.com/vercel/next.js/blob/3fd5b1c0b23546e1256f37ee7d705e255a4938e2/crates/next-core/src/next_import_map.rs#L1320-L1323
-
Jamiboy Mohammad authored
## Summary We've been enabling more e2e tests in deploy mode to increase coverage. Some of them are written with Vercel-specific assumptions, like Vercel's build directory, build-log format, or `vercel.json` handling. They fail when other platforms run the deploy suite against their own adapters. This PR adds a static `vercel` gate condition. It's true only in deploy runs with `NEXT_TEST_DEPLOY_TARGET_VERCEL=1`, which our Vercel deploy CI jobs set. Tests that depend on Vercel can then be skipped on other platforms: ```ts // @force-gate !deploy || vercel ``` The PR applies it to five recently enabled tests. This is a short-term measure; the goal is to make these tests work on every adapter. --------- Co-authored-by:Claude Opus 5.5 <noreply@anthropic.com>
-
Tobias Koppers authored
### What? Reland [#98862](https://github.com/vercel/next.js/pull/98862) after its revert in [#99227](https://github.com/vercel/next.js/pull/99227). Restore `next dev --custom-webpack` and `next build --custom-webpack`, CLI documentation, and the original e2e fixture, **without declaring webpack as a peer dependency**. `--webpack` continues using bundled webpack. ### Why? Allow applications to explicitly opt into their installed webpack version. The CLI records the absolute application directory before loading dev/build internals; config loading validates webpack, while Next.js's compiled webpack wrapper uses a project-scoped `createRequire` for every webpack import. This ensures `next.config.js`, user plugins, and Next.js compilation use the same webpack even if a different version is visible from inside the `next` package. Custom mode installs no webpack aliases; bundled mode keeps its explicit alias list. ### How? Restore the feature on post-revert canary without undoing intervening changes (including `next analyze`). Keep webpack as an application-installed dependency checked at opt-in time, rather than an npm peer in `next`'s published metadata. The e2e tests exercise webpack 5.98.0 and 5.111.0 in dev and production, config-time `require('webpack/package.json')`, custom and built-in plugins, the missing-install diagnostic, bundled fallback, and conflicting flags. A regression fixture disables pnpm hoisting and shadows webpack 5.98.0 beside `next` while the app installs 5.111.0; it proves Next still selects the app's instance. Another test builds with an explicit application directory from a different cwd. A dedicated Custom Webpack guide (shared between App and Pages Routers) includes install/usage examples and a pnpm `hoistPattern` note for plugins and workspace tooling that independently resolve webpack; both CLI option rows link to the guide. **Internal-sync caveat:** #99227 reports that declaring webpack as an optional peer introduced a dependency chain that duplicated Next.js in monorepos and broke internal sync. This reland **omits the peer declaration** to avoid that specific graph edge, while keeping runtime validation for `--custom-webpack`. The private dependency graph and sync reproduction are unavailable here; local tests do **not** independently prove internal sync is fixed. Maintainers should verify it before merging. **Local verification:** focused e2e **8/8 dev and 8/8 production** (plus targeted non-isolated checks for the two new tests), Next.js build and types, frozen lockfile install, changed-file ESLint, Prettier, and `pnpm types-and-precompiled` from a clean commit (no generated diff). Repo-wide `pnpm lint-eslint .` fails with a plugin-scope configuration error on the post-revert base as well (`import/no-extraneous-dependencies` cannot find plugin `import`); changed-file lint passes. **Review follow-up:** Restored the bundled-only `webpack/package` metadata alias and added config-time coverage for both extensionless and `.json` metadata imports. Per sokra's direction, no runtime version validation is added; the docs explicitly describe custom webpack as use at your own risk and list the tested versions without guaranteeing compatibility. **CI note:** Commit `51ebc4f9` passed docs-link, lint, types/precompiled, all production tests and changed-test flake runs, but a new explicit-directory case attempted `next build` inside a dev-mode shard and failed deterministically with a missing `.next/dev/trace`. The follow-up test-only commit `9d5c3d4e` instead exercises `next dev <appDir>` there and checks its HTTP output; it preserves the production `next build <appDir>` assertion. Focused dev and production e2e tests pass 8/8 locally; That commit's CI passed. Review follow-up `ed1c7bd0` also passed CI. The docs-only commit `10cbbd84` moves the setup section into the dedicated guide; its CI is running. The earlier docs-only commit also hit unrelated instant-validation snapshot mismatches, which were not rerun as flakes. <!-- NEXT_JS_LLM --> <!-- fleet 19431696-5f4c-400d-a3be-700bfe86abda --> --------- 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>
-