- 06 Oct, 2026 15 commits
-
-
next-js-bot[bot] authored
-
Aurora Scharff authored
## Summary - explain that request-time work conflicts with the route's static requirement without repeating “fully static” - align the overlay explanations, build messages, and error pages for route body, `generateMetadata()`, and `generateViewport()` errors - replace the cookie-specific runtime-data card with short browser-data pseudocode while preserving its existing docs anchor - update the affected build-output snapshots ## Verification - `pnpm jest packages/next/src/next-devtools/dev-overlay/components/instant/instant-guidance-data.test.ts` - formatted and linted all changed source, test, and MDX files - Not run: full package build (the isolated worktree reused an older dependency install that does not include the latest `@base-ui-components/react` packages) <!-- NEXT_JS_LLM -->
-
Aurora Scharff authored
## Summary - add API references for `turbopackGc`, `turbopackLazyDynamicImports`, `turbopackLazyDynamicImportsSSR`, and `turbopackPluginRuntimeStrategy` - document each option’s defaults, supported values, runtime behavior, and relevant limitations - cross-link related Turbopack configuration options ## Verification - Verified configuration types and defaults against the current config source and Turbopack tests - `pnpm prettier --with-node-modules --ignore-path .prettierignore --check <new-docs>` - `npx eslint --config eslint.config.mjs --fix <new-docs>` <!-- NEXT_JS_LLM --> --------- Co-authored-by:Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
-
Jiwon Choi authored
show choice for upgrade prompt | Before | After | | --- | --- | | <img src="https://github.com/devjiwonchoi/next.js/raw/604a56efdcbf2ead22d16c3098ae695eaff7558b/before.png" alt="Upgrade prompts before: answered prompts show only the question, hint and a blank gap" width="480"> | <img src="https://github.com/devjiwonchoi/next.js/raw/604a56efdcbf2ead22d16c3098ae695eaff7558b/after.png" alt="Upgrade prompts after: each answered prompt shows the confirmed choice" width="480"> |
-
Aurora Scharff authored
## Summary - add a **Keeping pages static** guide that applies `ensureStatic = 'shell'`, `'prefetch'`, and `'navigation'` to a store, then works through the validation errors and fixes in development - expand **Optimizing prefetching** around the App Shell, per-link prefetch, and navigation stages, including how `prefetch()` and `navigation()` defer cached work - align the `ensureStatic`, `instant`, `prefetch()`, and `navigation()` references with the guide and clarify how `instant = false` affects validation - document blocking generation for complete static output in the Cache Components ISR guide and update the related migration cross-links - add reusable docs-diagram tooling and the uploaded light and dark `ensure-static-visual` and `navigation-stage-visual` assets This PR is stacked on #97801. #99355 has merged. The Client fix cards, build-output category, and `#read-the-data-on-the-client` anchors used by the guide depend on #99659 and should land first. ## Verification - Prettier and ESLint passed for the latest documentation changes through the pre-commit checks - `bash -n .agents/skills/docs-diagrams/scripts/render.sh` - guide error ordering and route output were checked against development and build output <!-- NEXT_JS_LLM --> --------- Co-authored-by:Claude Fable 5.1 <noreply@anthropic.com>
-
Benjamin Woodruff authored
We don't need to add a file path to a batch and extend the batch deadline if the path isn't contained in the invalidator map. Prevents us from getting logspam like this: ``` Turbopack has seen frequent file updates and is waiting for the filesystem to settle (0.5s elapsed so far; last modified: "/Users/bgw/v0/chat/.next/dev/server/next-font-manifest.js"). ``` This is much less critical with the non-recursive watcher codepath, as we're only watching paths we might care about, but keeping it around in both cases helps ensure we get some CI coverage of this. I could put it behind `#[cfg(debug_assert)]` for non-recursive mode, IDK. --------- 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>
-
Aurora Scharff authored
## What? Adds an **Optimizing the static shell** guide that follows one team settings route through focused Suspense boundaries, deferred authentication, cache-versus-stream decisions, loading-state reuse, shared layouts, and parallel routes. Updates `next-cache-components-optimizer` to use that guide and the canonical Insight pages as its framework source of truth. The original phase-based Skill workflow is preserved, including the production rig, exact test contract, trustworthy RED-to-GREEN loop, parity check, differential, and reporting. Reusable implementation guidance now links to the corresponding guide section instead of being duplicated in Skill-only references. Clarifies that the optimizer can target either a direct page load or a named client navigation. Both use the same App Shell patterns and `instant()` verification loop. When the destination App Shell is already instant and the goal is to include additional URL-specific content before a click, the Skill hands off to the Partial Prefetching optimizer. Aligns the Cache Components and Partial Prefetching optimizers around the same workflow: define the contract, reuse the production rig, prove current behavior, make the smallest optimization, verify and ship. Their framework-specific decisions remain separate. The Partial Prefetching adoption rig also receives the shared visible, committed DOM-marker rule because it uses the same `instant()` testing API. ## Why? The optimizer's framework patterns are useful outside the agent workflow. Keeping them in public docs gives developers and agents one source of truth while each Skill stays focused on its product decision and reliable production verification. ## Eval The corrected-contract comparison uses Claude Opus 4.8 and Claude Sonnet 4.5 with a fixed Claude Haiku 4.5 judge. It compares the baseline, bundled guide, production Skill from `canary`, and proposed local Skill. The bundled-guide and Skill treatments use a local Next.js tarball containing the new guide. The eval now contains 11 granular checks so product behavior, test quality, and workflow discipline are visible independently. They cover configuration, direct and client-navigation `instant()` coverage, exact shell markers, preserved data sources, reusable and request-time UI placement, all completed-route variants, viewer-cookie behavior, trustworthy RED, full-suite GREEN, and the bounded differential. The prompt names the Aurora, Nebula, unknown-release, and viewer-cookie parity cases explicitly. All eight treatments were rerun against this 11-check rubric. | Model | Treatment | Checks passed | Overall | Duration | Tokens processed | Total run cost | Cost change | | --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | | Opus 4.8 | Baseline | 9/11 | Fail | 26m 38s | 4.83M | $4.66 | — | | Opus 4.8 | Bundled guide | 8/11 | Fail | 36m 36s | 4.99M | $5.29 | +13.5% | | Opus 4.8 | Production Skill | 9/11 | Fail | 28m 20s | 3.25M | $3.35 | -28.0% | | Opus 4.8 | Proposed Skill | **11/11** | **Pass** | 32m 9s | 5.25M | $5.24 | +12.5% | | Sonnet 4.5 | Baseline | 8/11 | Fail | 22m 31s | 2.73M | $1.29 | — | | Sonnet 4.5 | Bundled guide | 8/11 | Fail | 17m 58s | 2.38M | $1.18 | -8.1% | | Sonnet 4.5 | Production Skill | 4/11 | Fail | 27m 18s | 2.94M | $1.38 | +7.3% | | Sonnet 4.5 | Proposed Skill | 4/11 | Fail | 25m 26s | 5.49M | $2.53 | +96.1% | Token totals count each unique model message once and include uncached input, cache creation, cache reads, and output. Total run cost applies the current AI Gateway base rates to each token category. Judge cost is excluded. The eight runs processed 31.87M tokens and cost $24.91 in total, excluding the judge. This is one run per model and treatment, so the comparison is descriptive rather than a stable pass-rate measurement. The proposed Opus Skill is the only treatment to pass every check. Baseline and production Skill each passed 9/11, but both skipped the bounded differential. Baseline also missed the viewer-cookie timing lock. Production Skill omitted exact loading-state coverage. The guide-only treatment implemented the product behavior but missed an exact selector, trustworthy RED, and the differential. The proposed Sonnet Skill preserved the exact `instant()` contract, but replaced the existing runtime file read with a build-time import. It then stopped using the documented production command, encountered port conflicts from starting another Playwright server lifecycle, and never completed parity, GREEN, or a valid differential. This is a model adherence failure rather than a sandbox or credential failure. It shows that the restored workflow is sufficient for Opus but still too easy for Sonnet to abandon after it encounters test friction. ## Verification - Local Next.js build passed. - Prettier, TypeScript, ESLint through the commit hook, Alex, and diff checks passed. - Documentation link validation passed in CI. - All eight treatments finalized against the current 11-check rubric.
-
Jiwon Choi authored
-
Aurora Scharff authored
## Summary - Replace generic `Unauthorized` and `Forbidden` errors with the stable `unauthorized()` and `forbidden()` APIs across the mutating data, forms, Server Actions, data security, and `use server` documentation. - Distinguish unauthenticated requests from authenticated users who lack permission in the security examples. - Link to the API references and explain that the functions render the matching fallback files. This PR is stacked on #99696, which adds the complete pattern to the error-handling guide. ## Verification - `pnpm prettier --with-node-modules --ignore-path .prettierignore --write docs/01-app/01-getting-started/07-mutating-data.mdx docs/01-app/02-guides/data-security.mdx docs/01-app/02-guides/forms.mdx docs/01-app/02-guides/server-actions.mdx docs/01-app/03-api-reference/01-directives/use-server.mdx` - `pnpm exec eslint --config eslint.config.mjs --fix docs/01-app/01-getting-started/07-mutating-data.mdx docs/01-app/02-guides/data-security.mdx docs/01-app/02-guides/forms.mdx docs/01-app/02-guides/server-actions.mdx docs/01-app/03-api-reference/01-directives/use-server.mdx` - `NO_UPDATE_NOTIFIER=1 pnpm exec alex docs/01-app/01-getting-started/07-mutating-data.mdx docs/01-app/02-guides/data-security.mdx docs/01-app/02-guides/forms.mdx docs/01-app/02-guides/server-actions.mdx docs/01-app/03-api-reference/01-directives/use-server.mdx --quiet` - Not run: framework tests (documentation-only change) <!-- NEXT_JS_LLM -->
-
Aurora Scharff authored
## Summary - Recommend `unauthorized()` for unauthenticated requests and `forbidden()` for authenticated users without access. - Add `Suspense` boundaries around the request-time reads in the existing `notFound()` example and the new authentication example so both patterns work with Cache Components. - Add corresponding `unauthorized` and `forbidden` fallback UI examples and clarify when to use `redirect()` for sign-in flows. - Document eager fallback rendering consistently across the `error.js`, `not-found.js`, `unauthorized.js`, and `forbidden.js` references, with links between the related conventions. This builds on #99689, which stabilizes the authentication interruption APIs. ## Verification - `pnpm prettier --with-node-modules --ignore-path .prettierignore --write docs/01-app/01-getting-started/10-error-handling.mdx docs/01-app/03-api-reference/03-file-conventions/error.mdx docs/01-app/03-api-reference/03-file-conventions/not-found.mdx docs/01-app/03-api-reference/03-file-conventions/forbidden.mdx docs/01-app/03-api-reference/03-file-conventions/unauthorized.mdx` - `pnpm exec eslint --config eslint.config.mjs --fix docs/01-app/01-getting-started/10-error-handling.mdx docs/01-app/03-api-reference/03-file-conventions/error.mdx docs/01-app/03-api-reference/03-file-conventions/not-found.mdx docs/01-app/03-api-reference/03-file-conventions/forbidden.mdx docs/01-app/03-api-reference/03-file-conventions/unauthorized.mdx` - `NO_UPDATE_NOTIFIER=1 pnpm exec alex docs/01-app/01-getting-started/10-error-handling.mdx docs/01-app/03-api-reference/03-file-conventions/error.mdx docs/01-app/03-api-reference/03-file-conventions/not-found.mdx docs/01-app/03-api-reference/03-file-conventions/forbidden.mdx docs/01-app/03-api-reference/03-file-conventions/unauthorized.mdx --quiet` - Not run: framework tests (documentation-only change) <!-- NEXT_JS_LLM -->
-
Benjamin Woodruff authored
Caused by: https://github.com/vercel/next.js/pull/99406 Failure: https://github.com/vercel/next.js/actions/runs/37390479841/attempts/2 Re-running with this PR here: https://github.com/vercel/next.js/actions/runs/37404978916
-
Will Binns-Smith authored
## Summary Make the bundle analyzer explain how emitted chunks can load other chunks. This gives the initial-load optimizer skill the relationships it needs to distinguish startup code from conditionally loaded code and trace why a dependency is reachable. - Export typed load relationships for dynamic imports, async manifests, and service-worker registration. - Tie async triggers to the actual dynamically imported module. - Preserve unresolved relationships and worker modules compiled in separate graphs so missing data is not mistaken for “nothing loads.” This builds on the preceding branch’s client chunk groups and machine-readable graph export. The relationships describe possible loads at build time; browser measurements are still needed to establish what actually loads initially. ## Verification - Previously reported: Next.js package no-emit types passed. - Native dev/prod analyzer e2e and a full Rust build were not run locally due to sandbox disk capacity. Current-head CI must validate them; earlier-head results do not verify this stack. - Analyzer graph-dump and snapshot-selection unit suites were removed earlier in the stack. Their malformed-data, stream, collision, packaging, and mocked-history/path coverage has no replacement. <!-- NEXT_JS_LLM --> <!-- fleet d7bdbc2b-b0bc-4591-99eb-dccb0fa49c73 --> <!-- fleet ea768377-d71c-4a15-90b2-f4d50d4f6a1c --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
-
Will Binns-Smith authored
## Summary This PR exposes **chunk groups**: sets of generated client files that the build associates with a route's client entry or with client components and layouts used by that route. They show how files relate to route code, beyond which modules ended up in any one file. When a route's client output is large, the groups help an agent narrow which related files and code to inspect. A file can appear in more than one group, and layout groups can include files from multiple levels. Groups do **not** show when a browser requests a file or how many bytes one component added; overlapping groups must not be added together as independent file sets. ## Verification - The broad graph-dump converter unit suite is removed in the root and not reintroduced here; existing e2e and producer code are unchanged. The snapshot-selection unit suite is removed too, without replacement tests; its targeted mocked-history/path coverage is intentionally dropped. Neither analyzer unit suite remains; Next package no-emit types pass. Unique removed edge-case coverage was explicitly accepted. - Earlier stack verification included Rust analyzer tests, analyzer e2e and a full build; these are historical results, not validation of the new signed heads. **New-head CI is pending.** <!-- NEXT_JS_LLM --> <!-- fleet d7bdbc2b-b0bc-4591-99eb-dccb0fa49c73 --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
-
Will Binns-Smith authored
## Summary Before this PR, an agent could see a route's generated files and follow imports to find modules relevant to that route. It could not reliably tell **which exact modules landed in a particular JavaScript or CSS file**. This PR adds that per-file mapping, so an agent can trace a large generated file back to the modules it contains. Files that cannot be mapped are marked as such rather than shown as empty. The graph checks the module information before reporting a match. ## Verification - The broad graph-dump converter unit suite is removed in the root and not reintroduced here; existing e2e and producer code are unchanged. The snapshot-selection unit suite is removed too, without replacement tests; its targeted mocked-history/path coverage is intentionally dropped. Neither analyzer unit suite remains; Next package no-emit types pass. Unique removed edge-case coverage was explicitly accepted. - Earlier stack verification included Rust analyzer tests, analyzer e2e and a full build; these are historical results, not validation of the new signed heads. **New-head CI is pending.** <!-- NEXT_JS_LLM --> <!-- fleet d7bdbc2b-b0bc-4591-99eb-dccb0fa49c73 --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
-
Will Binns-Smith authored
## Summary Export typed App, Pages and API endpoint roots and nested client references from analyzer route provenance into JSON Lines `route.entries`. Keep server/shared roles separate from verified client bootstrap identities: a client reference is not another endpoint or evidence of an observed initial request. Preserve UI binary artifacts internally while agents consume semantic records. ## Verification - This layer: root TypeScript and converter unit 5/5; targeted Rust analyzer tests 3/3. Completed stack: analyzer e2e 7/7 (App, Pages, API), full build 18/18. New-head CI pending. <!-- NEXT_JS_LLM --> <!-- fleet d7bdbc2b-b0bc-4591-99eb-dccb0fa49c73 --> <!-- fleet ea768377-d71c-4a15-90b2-f4d50d4f6a1c --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
-
- 05 Oct, 2026 25 commits
-
-
Luke Sandberg authored
### What? When GC collects a task, it removes each dependent's forward edge to it, as before, but no longer marks the dependent dirty. ### Why? The dirty never helps, the dependent task's previous execution is still valid. But it is also 'stale', no task should ever read it again, so providing a hint that it should be recomputed is harmful. Such a task is in a "dead but doesn't know it yet" state and so we can ignore it until its parent disconnects it. We still need to remove the edges so when the dependent is itself collected it doesn't panic because its dependencies have disappeared.
-
Luke Sandberg authored
### What? - Reading a cell or output of a task that no longer exists returns an ordinary error instead of panicking. That covers a task collected by GC, whether still soft-deleted in memory or already evicted. `lock_task_and_optional_reader` opens the target with `AllowMissing` and returns before any dependency edge is added. - `connect_task` skips the connect when the task no longer exists. The output read that follows then fails with the same error. - `MustExist` stays everywhere in edge maintenance (cleanup, aggregation, `task_pair`), where a missing task means a GC bug. ### Why? GC does not keep a cell producer alive for its dependents, so a stale task can hold a collected task's `Vc` in its **arguments**. Such a task is in a "dead but doesn't know it yet" state but it still may be optimistically executed, so these errors are expected in 'eventual consistency cases'. `connect_task` had a worse version. An `OperationVc` held without a pin can name a collected task. Connecting it from outside any task (a top-level `run`, as NAPI code would) materialized a blank entry, scheduled it, and its execution panicked outside the per-task panic boundary, aborting the process. This is considered a bug, the caller should have added a 'pin' but in the mean time we can regularize the failure mode. ### How? New tests in `tests/gc_cross_session.rs`: - `reading_a_collected_task_is_an_error`: a reader holds the collected target in its arguments and re-executes. - `connecting_a_soft_deleted_operation_is_an_error` and `connecting_an_evicted_collected_operation_is_an_error`: a task holds an `OperationVc` it never connected, and connects it after the operation is collected. - `parentless_connect_of_an_evicted_operation_does_not_abort`: also asserts no entry is materialized.
-
Luke Sandberg authored
### What? When `task_pair` or `prepare_tasks` opens a task that is missing from disk (`MustExist`), or a restore hits an I/O error, it panics. They had already pinned the tasks involved (`transient_ref_count += 1`) and never released those pins. Because the missing task was still pinned, its entry also stayed in the map. Those pins weren't needed, so this removes them instead of making their release more careful: - `restore_task`, `prepare_tasks` and `task_pair` no longer pin a task while they use its id without holding its lock. - `handle_missing_task` always discards a missing task's entry. A missing task can't hold a transient reference, because those are only taken on tasks that exist; this is now a debug assertion. A thread still using the id creates a new entry, finds the task missing itself, and discards that entry too. - `task_pair` discards the entry it created for a missing transient endpoint before panicking. - `prepare_tasks` keeps handing off every task that does exist and reports missing tasks and I/O errors once at the end. - `prepare_tasks_with_callback` now documents that its callback must not panic. A panic there is a backend bug, expected to abort. One in Phase 1a can leave this batch's restoring claims set. ### Why? Previously I considered these panics to be fatal, so being careful about the pins leaking or the entries being discarded wasn't important. But these panics are sometimes caught by turbo-task functions. If the failure doesn't propagate then the session will complete and confuse the GC cycle later (since we have 'restored' a task that is completely blank). The pins don't protect anything: - **Outside a GC pass:** every `ExecuteContext` holds an operation guard, so GC can't run while a task id is held without its lock. - **Inside a GC pass,** where shard scans overlap with collects: - An edge that keeps the task alive (child, upper) also keeps it from being collected until that edge is removed. - A dependency edge doesn't keep it alive, but a concurrent collect is harmless then: edits during the cascade are idempotent removals, and edge additions are guarded by `assert_not_deleted`. - **Eviction** never drops a category that has a restoring claim, and the restore loop retries if a category was evicted while it waited. ### How? Unit tests in `operation/mod.rs` catch the missing-task panic and assert that no task stays pinned and no entry is left for the missing one: - `task_pair_missing_endpoint_leaves_no_pins` - `task_pair_missing_transient_endpoint_leaves_no_entry`, which fails without the fix - `prepare_tasks_missing_task_hands_off_the_rest_and_leaves_no_pins` The GC suites (`gc_stress`, `parent_count`, `gc_cross_session`, `gc_resurrection`, `gc_collection`, `gc_interrupt`, `detached`) passed 5 times in a row with debug assertions on.
-
Will Binns-Smith authored
## Summary Add a model-discoverable browser initial-load optimizer for slow route startup, oversized client bundles, duplicate browser dependencies and interaction-gated features. The skill follows six ordered steps with observable completion gates: scope, baseline, validation, candidate, one verified fix, report. Audit is the default and leaves app source/dependencies/lockfiles unchanged; fixing requires an explicit request. The shared workflow keeps capture/replay (including saved-snapshot reuse), a complete `--route` command, installed-schema validation and evidence-qualified reporting visible. The v1 schema in the app's installed `next` package remains the field/record authority; the skill covers complete-stream, join and source checks that per-record validation cannot establish. Optional CLI choices defer to installed `next analyze --help`. Conditional plain references carry graph clustering/min-cut procedures and lazy-feature/package-dedupe/server-display checks. Agents load them only when the candidate reaches that branch. The main skill is 49% shorter by character count, preserving authorization, graph completeness and behavior safeguards. Related-skill pointers sit beside their triggering branches. This PR owns the skill and AI-agent guide entry; the root/producer PRs own CLI/schema/data contracts. ## Verification - Prettier, skill/reference language lint, frontmatter/invocation checks, six completion gates, relative-pointer checks and installed-like recursive file discovery pass. Static scenario walkthroughs cover audit/fix, saved replay, custom directories, blocked/corrupt exports, incomplete graph evidence and each fix branch. The existing eval installer copies skill reference files recursively. - This writing-only pass changes four Markdown files across the eight skill-bearing layers; the root, installed schema, runtime/Rust, evals, tests and executable modes are unchanged. No removed unit suite is reintroduced. Earlier no-emit/runtime-probe/package checks are separate evidence, not rerun for prose. - Full model-driven evals and native e2e were not run locally. Shorter text and static checks are not evidence of better agent outcomes. New-head CI must establish its own status. <!-- NEXT_JS_LLM --> <!-- fleet d7bdbc2b-b0bc-4591-99eb-dccb0fa49c73 --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
-
next-js-bot[bot] authored
-
Benjamin Woodruff authored
Turbopack: Cache canonicalized paths without turbo-tasks, try to find the longest cached prefix first (#99270) When converting from an absolute system path to a filesystem-relative path, we'd first try to lexically `strip_prefix`, but if that failed, we'd fall back to trying to canonicalize the root path before stripping. Because we don't know how many of the path segments refer to the root, we have to canonicalize one path segment at a time. With turbo-tasks, we have to probe the cache once per path segment, starting from the shortest possible path segment. This removes the `turbo_tasks::function` we were using to cache the canonicalization calls, and instead stores caches in `BTreeMap`s. This lets us efficiently look up the longest matching prefix in the cache, which (in the happy path) should be a match for a filesystem root. ## Possible concerns - ~We have duplicated canonicalization caches, one for the map, one for each `DiskFileSystem`. Would a per-process (`OnceLock`) cache of canonicalization calls make more sense?~ We now prefer lookups in the map, which effectively solves this. - A `PatriciaMap` would likely be more space efficient. `PatriciaMap` is currently only used in `AliasMap`: https://github.com/vercel/next.js/blob/ff6ac752af572467f35187e421dd7e558797b412/turbopack/crates/turbopack-core/src/resolve/alias_map.rs#L16 ## Things I don't think are concerns - `RwLock`: If we have a lot of writes, that means we're spending a lot of time doing canonicalization, which would be a bigger problem than locking.
-
Josh Story authored
## Summary The experimental parameter matching APIs may not yet be supported by some hosts that package Next.js builds without adapters. Add an optional `__private_unstable_hasParamMatching: true` field to `prerender-manifest.json` so those hosts can temporarily detect API usage and warn about unsupported deployments rather than infer it from generated routing behavior. The field records evaluated layout and page exports, including generators, empty fragments, and overridden configuration. It is omitted when matching configuration was not evaluated and disappears when rebuilding after the last export is removed. This private field is temporary and will be removed; it is not a lasting API-usage signal. This is host-neutral metadata only: it adds no deployment restriction, changes no runtime behavior, and does not change the public adapter interface. ## Verification - Production fixture passes with Turbopack and webpack: 6 cases each covering usage, absence, and rebuild cleanup. - An ordinary full `next build`, without route filtering, also emits the marker. - Type checking and formatting/lint checks pass. <!-- NEXT_JS_LLM -->
-
Will Binns-Smith authored
## Summary Separate analyzer capture from versioned JSON Lines graph replay. `next analyze` builds the analyzer data and serves its UI; `next analyze --output --snapshot-name <name>` saves the usual binary snapshot and UI without serving. `next analyze --export-graph --snapshot-name <name>` reads a saved snapshot and streams one typed JSON record per line **without building or spawning a child**. Bare `--export-graph` reads the newest snapshot; `--snapshot <id>` selects an exact generated ID, and `--route` filters route records. Replay rejects a duplicate/missing name and an explicit `--port`, but accepts inherited `PORT`. Capture honors the configured `distDir` and holds Next's existing build lock from before Turbopack writes through snapshot completion (or until the UI exits). SWC bindings are installed **before** acquiring that native lock. Replay does not load the app config: apps using a custom directory pass `--dist-dir <relative-dir>` explicitly, leaving stdout as JSON Lines. The authoritative v1 record schema ships with the installed `next` package at `next/analyze/graph-v1.schema.json`; this root layer exports verified base fields, and the stacked producer PRs add typed roots, output membership and load relationships. The former `--output=json` shortcut and `--graph-json` spelling are intentionally rejected. Analyzer-owned filesystem work uses synchronous I/O for capture setup, snapshot persistence/history pruning and graph reads. Export keeps stdout drain handling and validates selected route data before emitting; serial reads do not eliminate retained route-buffer memory. ## Verification - Removed the broad `analyze-graph-dump.test.ts` fixture suite from this root and all descendants, leaving existing e2e unchanged. This intentionally drops unique malformed-input, stream/backpressure, collision and package-allowlist checks as agreed. Also removed `analyze-snapshot-selection.test.ts` (254 lines) without replacements; targeted mocked-history/path coverage is intentionally dropped. Neither analyzer unit suite remains. Next package no-emit types, ESLint and formatting pass across the distinct code layers. Scratch runtime probes match prior export bytes, check route filtering, corruption-before-output, drain/error behavior and snapshot history/pruning/cleanup. Existing e2e/schema/producer/skill files are unchanged; this pass changes four source files to use synchronous analyzer I/O. Earlier packaging checks confirmed the schema in a packed tarball. - Native e2e/full Rust build cannot run in this disk-limited sandbox. Prior head `39726552` passed the analyzer changed-test dev/prod jobs; **new-head CI is still required**. Its full CI had separate failures outside analyzer tests. Full model-driven agent evals were not run locally. <!-- NEXT_JS_LLM --> <!-- fleet d7bdbc2b-b0bc-4591-99eb-dccb0fa49c73 --> <!-- fleet ea768377-d71c-4a15-90b2-f4d50d4f6a1c --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
-
Benjamin Woodruff authored
Also reverts https://github.com/vercel/next.js/pull/99621 Discussion: https://vercel.slack.com/archives/C04KC8A53T7/p1791231703532919?thread_ts=1791230213.615279&cid=C04KC8A53T7 This code depends on the exact format used for exports
😢 😠 : https://github.com/vercel/remote-components/blob/201b460403d5813f632b687fab1ad2fc2ce4174b/packages/remote-components/src/runtime/turbopack/module.ts#L380-L401 -
Janka Uryga authored
Closes NAR-959 Sync IO can deopt the result of a runtime prerender, both in a runtime request and in the embedded runtime prefetch stream. Long ago, we decided to not log these errors, with the motivation that: 1. The user didn't opt into the runtime prefetch stream 2. They are not reproducible in dev However: - 1 is now no longer invalid, because the runtime prefetch stream is only enabled in PPF, which _is_ an opt in. - 2 is no longer valid, because opening the page in dev reliably reproduces sync IO errors in cacheable content (see [tests](https://github.com/vercel/next.js/blob/41215d77762375b4b5154b12cfbb4372a835f8a0/test/e2e/app-dir/instant-validation/sync-io-and-blocking.util.ts#L21)) ...so we can now start logging the errors again. This helps the user notice that the deopt is occurring, which they can then go reproduce in dev.
-
Jan Kassens authored
Clarifies that `"use client"` is a file level directive and cannot be placed inside components. Some of the wording suggested to me that it could work inside of components similar to `"use server"` which is allowed inside functions.
-
Andrew Clark authored
Moves the `forbidden()` and `unauthorized()` out of experimental and deprecate the feature flag (`authInterrupts`) that they were gated behind. One caveat with these APIs is that the `forbidden.ts`/`unauthorized.ts` boundaries are sent down eagerly as part of the normal page render. We plan to optimize this later so they are only rendered lazily. (It's the same optimization planned for error and not-found pages.) <!-- NEXT_JS_LLM -->
-
Luke Sandberg authored
## Summary Most of the Turbopack runtime in `turbopack-ecmascript-runtime/js/src` was never type-checked, and editors showed hundreds of bogus "Cannot find name" errors in it. - `src/nodejs/tsconfig.json` had `"include": ["*.ts"]`, which only matched `nodejs/hmr-types.d.ts`. So `nodejs/runtime/*` and `nodejs/dev/*` were in no project, and `pnpm check` never covered them. - `browser/runtime/base/tsconfig.json` included only `runtime-base.ts` and `dummy.ts`. `build-base.ts`, `dev-base.ts` and `dev-dummy.ts` were left out. `dev-base.ts` was checked indirectly through the `dom` project. - tsserver then fell back to `turbopack/tsconfig.json`, which uses `"module": "NodeNext"`. That implies `moduleDetection: force`, so these global-script files were treated as modules and their shared `/// <reference>` declarations disappeared. `build-base.ts` and `dev-base.ts` are alternative entry points that both define `instantiateModule`, so they can't share a project. In both `nodejs/` and `browser/runtime/base/`, `tsconfig.json` is now a solution-style config that references a `tsconfig.build.json` and a `tsconfig.dev.json`. tsserver follows these references, so every file opens in the right project. Files that are only pulled in through `/// <reference>` are listed in `include` explicitly, because tsserver doesn't otherwise count them as part of a project. The `check:` scripts are split the same way. `tsconfig.base.json` now sets `moduleDetection: "auto"` explicitly. That's already the default for `module: CommonJS`, but it documents that these files have to stay scripts. This also fixes the errors in files that were never checked before: - `nodejs-globals.d.ts` referenced `shared/runtime-types.d.ts`, which doesn't exist. The file is `shared/runtime/runtime-types.d.ts`. - In `nodejs/runtime/build-base.ts`, `moduleCache.get(...)` returned `Module` where `ModuleWithDirection` was expected. This matches the existing cast on `nodeContextPrototype.c`. - `nodejs/dev/dev-nodejs.ts` read `.merged` on an instruction union where only `ChunkListUpdate` has that field. - `nodejs/runtime/dev-base.ts` had an unused parameter. ## Verification - `pnpm check` in `turbopack/crates/turbopack-ecmascript-runtime/js` passes. - Opened all 31 `.ts` files in a real tsserver. Each resolves to one of this package's tsconfigs, with 0 errors. - Not run: Turbopack snapshot tests. The `dev-nodejs.ts` change affects emitted runtime code, so snapshots may need regenerating. <!-- NEXT_JS_LLM -->
-
Janka Uryga authored
Reworks `use-cache-search-params` to fix flakiness. The "/search-params-caught" test [occasionally fails like this](https://github.com/vercel/next.js/actions/runs/37332777301/job/111840698762#step:35:9635). i'm not sure what this is exactly (the prerender for the page fails without logging the specific error?), but using separate prerenders for each page seems to work around that, and that's what we should be doing for build failures anyway.
-
Josh Story authored
## Summary Static export currently installs an identity `exportPathMap` callback on the resolved config when no callback is configured. Use the default path map directly while preserving configured callbacks. This removes another config mutation as part of immutable configuration support for adapters. ## Verification - `pnpm test-start-webpack test/production/fallback-export-error/index.test.ts` (4 passed, covering default, valid custom, and invalid custom path maps) <!-- NEXT_JS_LLM -->
-
Josh Story authored
## Summary Pass the build manifest's compile-mode marker separately to server rendering, leaving the loaded configuration unchanged. This supports immutable Next.js configuration for adapters without introducing another mutable config representation. Preserve the manifest override, including a false or absent marker, and the existing config fallback when the manifest cannot be read. ## Verification - `pnpm test-start-webpack test/e2e/app-dir/app/experimental-compile.test.ts -t 'should provide query for getStaticProps page correctly|should run generate command correctly'` (2 passed) <!-- NEXT_JS_LLM -->
-
Josh Story authored
## Summary Keep custom-server asset prefix changes in server render state, with rendering and routing reading the same runtime value. Setting and resetting the prefix continues to work without modifying or copying the loaded config. This supports the broader effort to make Next.js configuration immutable for adapters. Adds a public custom-server test for App Router asset URLs, including reset to an empty prefix. ## Verification - Existing Pages custom-server dynamic-prefix tests pass in production with Webpack and development with Turbopack (24 cases each). - The production custom-server suite passes with Webpack; the new App Router case also passes with Turbopack. <!-- NEXT_JS_LLM -->
-
Jamiboy Mohammad authored
## Summary `eslint-config-next` crashes under ESLint 10. This makes it work with both ESLint 9 and 10 without raising Next.js's Node.js minimum (`>=20.9.0`). ESLint 10 itself requires Node.js `^20.19.0 || ^22.13.0 || >=24`, so users on older Node.js 20 versions keep using ESLint 9. ### Upgraded Dependencies that already have releases declaring ESLint 10 support: - `typescript-eslint` `^8.46.0` → `^8.56.0` - `eslint-plugin-react-hooks` `^7.0.0` → `^7.1.0`. 7.1 removed the deprecated `react-hooks/component-hook-factories` rule (now a no-op) from its recommended config, so it's no longer enabled. Fresh installs of the previous `^7.0.0` range already get this version. ### Patched Dependencies with no ESLint 10–compatible release that Next.js can use. The plugin versions below are their latest releases. Their behavior is adapted in `eslint-config-next`; the patches do nothing under ESLint 9. - **Babel parser** (`@babel/eslint-parser` 7.24.6, bundled in `next`): ESLint 10 registers configured and inline (`/* global */`) globals through `scopeManager.addGlobals()`, which this parser's scope manager doesn't have (`TypeError: scopeManager.addGlobals is not a function`). `eslint-config-next/parser` adds it, doing the same scope maintenance ESLint 9 did itself. Babel 8's parser supports ESLint 10 but requires Node.js `^22.18 || >=24.11`. The parser comes from the user's installed `next`, so the method is only added when it's missing. - **`eslint-plugin-react`** (7.37.5) and **`eslint-plugin-import`** (2.32.0): ESLint 10 removed the rule context members `getCwd()`, `getFilename()`, `getPhysicalFilename()`, `getSourceCode()`, `parserOptions` and `parserPath`. `eslint-plugin-react` calls them for `settings.react.version: 'detect'`, and rules such as `import/no-default-export` read `parserOptions`. The rules are patched in place to restore these members, so the plugin objects keep their identity; a wrapped copy breaks configs that also use the plugin's own configs (`Cannot redefine plugin "react"`). - **Import resolvers**: `eslint-plugin-import` loads the configured resolvers by name from the linted file. With ESLint 10, npm doesn't hoist `eslint-plugin-import` and `eslint-import-resolver-typescript` because of the plugin's peer range, so the lookup falls back to the `typescript` package (`Resolve error: typescript with invalid interface loaded as resolver`) and rules such as `import/no-unresolved` can't resolve TypeScript path aliases. The resolvers are referenced by their resolved paths again, as before the flat config rewrite (#84874). As in v15, a user's own `import/resolver` entries are used in addition to these rather than replacing them. ### Unchanged - `eslint-plugin-jsx-a11y` (6.10.2) and `@next/eslint-plugin-next` don't use the removed APIs, and `eslint-plugin-react-hooks` falls back to their replacements. - `eslint-plugin-jsx-a11y` 6.10.2 is its latest release, so there's no newer version to upgrade to. ### Other - **Docs**: ESLint 10 support, its Node.js requirement, and the peer dependency warnings. - **Build**: `@types/node` added as a dev dependency with `"types": ["node"]`, since TypeScript 6 no longer includes `@types` packages automatically and the config now uses `require.resolve`. ### Known limitations `eslint-plugin-react`, `eslint-plugin-import` and `eslint-plugin-jsx-a11y` don't list ESLint 10 in their peer dependencies yet. Until they publish releases that do: - Installs with ESLint 10 show peer dependency warnings (`npm warn ERESOLVE overriding peer dependency`, pnpm `unmet peer`), but succeed and lint correctly. - Installs with strict peer dependencies fail. - With npm, projects that list `eslint-plugin-react` as a direct dependency fail with `ERESOLVE` unless installed with `--legacy-peer-deps` or `--force`, because npm treats peer conflicts in the project's own dependencies as errors. ## Verification - New `test/production/eslint-config-next` test, which installs the packed config with ESLint 9.37.0 and 10.11.0 and requires both to report the same diagnostics for a JavaScript project (Babel parser) and a TypeScript project (typescript-eslint parser). A third case installs with npm and ESLint 10, where the plugins and resolvers are nested under `eslint-config-next`. Disabling each patch in the ESLint 10 installs makes ESLint crash, throw a config error, or fail to resolve imports, so the test fails. - CI runs the test on Node.js 20.9.0. <!-- NEXT_JS_LLM -->
-
Aurora Scharff authored
Closes NAR-929 ## Summary - add render stages in validation so Instant Navigation validation can distinguish `prefetch()` from URL data - report `prefetch()` and `navigation()` consistently across route bodies, metadata, and viewport - show non-blocking findings as amber Instant Insights while keeping prerender failures as red errors - document navigation stages and cross-link the stable `prefetch()` and `navigation()` APIs from their references and the Optimizing Prefetching guide The DevTools cards, terminal guidance, and error pages use the same recommended fixes. Metadata guidance lets developers remove the stage API or confirm the delay from the page. Viewport guidance lets developers remove the API or disable validation with `instant = false`. ## Implementation notes Adds two new sub-stages that are only used for dynamic hole discrimination: - `PrefetchStatic_prefetch` (subset of `PrefetchStatic`) - `PrefetchRuntime_prefetch` (subset of `PrefetchRuntime`) The stages run before the semantic `PrefetchStatic` and `PrefetchRuntime` stages respectively. We resolve `prefetch()` resolves there in renders that produce validation error messages. the validation sequences map the stages to a prefetch() hole kind and produce a specialized error message, distinct from URL data. In non-validation renders, we skip the sub-stages and advance to `PrefetchStatic`/`PrefetchRuntime` directly, which resolves `prefetch()` in the same task as other URL data. We also reorganize `RENDER_STAGES_BY_DATA_KIND`. We have `staticUrlData['static' | 'runtime']` to separate data that is _semantically_ statically prerenderable (but may be deferred to a runtime stage for implementation reasons) from `runtimeUrlData`, which is never statically prerenderable. ## Preview scenarios - [`navigation()` outside of Suspense](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/119-navigation-body) - [`navigation()` in `generateMetadata()`](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/120-navigation-in-metadata) - [`navigation()` in `generateViewport()`](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/121-navigation-in-viewport) - [`prefetch()` outside of Suspense](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/122-prefetch-body) - [`prefetch()` in `generateMetadata()`](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/123-prefetch-in-metadata) - [`prefetch()` in `generateViewport()`](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/124-prefetch-in-viewport) ## Verification - 145 focused DevTools unit tests - 108 Partial Prefetching Instant Validation tests, including 64 snapshots - 32 Instant Navigation DevTools tests - `pnpm --filter=next types` - `pnpm --filter=next build` - Documentation link validation passed <!-- NEXT_JS_LLM --> Co-authored-by:
Janka Uryga <lolzatu2@gmail.com> Co-authored-by:
Claude Fable 5.1 <noreply@anthropic.com>
-
Janka Uryga authored
Aligns runtime stage naming with the static stages. We used to call this the `Runtime` stage, but now we have the concept of navigation stages ("shell"/"prefetch"/"navigation") and we want to align the render stage names with the navigation stage they correspond to (i.e. which content they unblock), so it should be called `PrefetchRuntime` now. (longer-term, i also want to fold `Static*` and `Runtime*` together, and only use the navigation stage names, but this will take more work, so we're not doing this now) -
Hendrik Liebau authored
-
Aurora Scharff authored
## Summary - add a Client fix to both runtime-data and uncached-data errors on fully static routes - document client URL hooks, browser APIs such as non-`HttpOnly` cookies, and client-side fetching as distinct patterns - keep the combined runtime-or-uncached classification in the blocking build message instead of adding a third overlay card variant - omit the Cache card when a fully static error points to `connection()`, matching the existing blocking-route behavior - align build guidance, overlay cards, error pages, and tests ## Design and capture review - [Runtime data](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/125-ensure-static-cookies) - [Uncached data](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/128-ensure-static-uncached) - [`connection()`](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/129-ensure-static-connection) ## Verification - `pnpm exec jest --runInBand packages/next/src/next-devtools/dev-overlay/components/instant/instant-guidance-data.test.ts packages/next/src/next-devtools/dev-overlay/container/errors.test.ts` (139 tests passed) - Prettier and ESLint passed for the changed files - Focused e2e snapshots left to CI <!-- NEXT_JS_LLM -->
-
Aurora Scharff authored
## Summary - Link to the Partial Prefetching adoption guide and clarify how the existing hover-triggered `<Link>` example changes - Use `auto` before intent to preserve the shared App Shell prefetch, then use `true` to resolve cached URL-specific content - Explain that `prefetch={false}` also disables the App Shell prefetch ## Verification - `pnpm prettier --with-node-modules --ignore-path .prettierignore --write docs/01-app/02-guides/prefetching.mdx docs/01-app/02-guides/optimizing-prefetching.mdx` - `pnpm exec eslint --config eslint.config.mjs --fix docs/01-app/02-guides/prefetching.mdx docs/01-app/02-guides/optimizing-prefetching.mdx` - `git diff --check origin/canary...HEAD` <!-- NEXT_JS_LLM --> -
Niklas Mischkulnig authored
Sort the collected env vars before returning. They were already deterministic, but this normalizes the return value more (previously changing the module graph might have changed the order of these lists)
-
Luke Sandberg authored
## Summary `pnpm build-all` decides whether to build the native binary with `packages/next-swc/maybe-build-native.mjs`. That script `git diff`s against the last version-bump commit, and only builds when `.rs`, `.toml`, `.cargo/**`, `Cargo.lock` or `rust-toolchain` files changed. Several crates compile a `js/src` directory into the binary with `embed_directory!`: next-core, turbopack-ecmascript-runtime, turbopack-ecmascript, turbopack-node, turbopack-wasm and turbopack-cli. Editing only those files counted as "no Rust changes", so the script skipped the build. It then deleted the local `native/*.node` in favor of the prebuilt npm binary, so local runtime changes silently never took effect. This adds `crates/*/js/src/**` and `turbopack/crates/*/js/src/**` to the pathspec. ## Verification - With only `turbopack-ecmascript-runtime/js/src` files modified, the `git diff --name-only` in `hasRustChanges` now lists them, so the build runs. Before this change it printed nothing. <!-- NEXT_JS_LLM -->
-