- 06 Oct, 2026 23 commits
-
-
next-js-bot[bot] authored
-
Jan Kassens authored
The world of AI is moving fast. Instead of hardcoding the available models, discover them from the CLIs. This is a bit hacky, but probably more reliable than hardcoding a list that will become outdated fast. The available models might be different for different accounts. This involved a bit of code moving as I wanted to have the model discovery run in parallel to displaying the user the harness selection to reduce delay in selecting the model. ## Test Plan: In addition to new tests, also tested interactively with: ``` DEBUG=next:upgrade node -e \ "require('./packages/next/dist/lib/upgrade/harness').handoffUpgrade('This is a harness test. Do not modify files.', process.cwd(), null).catch(console.error)" ``` -
next-js-bot[bot] authored
-
Will Binns-Smith authored
## Summary Document `next analyze export` with a snapshot capture/export example and a link to its CLI options. ## Verification - Prettier and ESLint passed. - Runtime tests not run (docs only). <!-- NEXT_JS_LLM -->
-
Andrew Clark authored
Stabilizing `forbidden()` and `unauthorized()` means the built-in 403 and 401 fallbacks are rendered into every page's payload, even for apps that don't define `forbidden.tsx` or `unauthorized.tsx`. On a fresh create-next-app that's about 2.3KB of uncompressed HTML per page (~125 bytes gzipped). I knew about the regression but I forgot that it applied to every app and every page, rather than just those that use `forbidden.tsx` or `unauthorized.tsx`. To avoid blocking the 16.4 release, we'll keep this feature in experimental for now until we fix the implementation to render the fallbacks lazily.
🤖 Generated with [Claude Code](https://claude.com/claude-code) -
Josh Story authored
## Summary Static export with a custom `distDir` currently overwrites that option with `.next` during the build. Keep the configured export destination intact and derive the intermediate build directory separately, so adapters receive the original option while their build-directory argument still points to the artifacts. This removes a post-load config mutation as part of making completed configuration immutable for adapters and other runtime consumers. Preserve support for both relative and absolute Turbopack project output paths. ## Verification - Existing adapter tests pass in both production bundlers; custom export-directory coverage passes with Turbopack. - Existing server trace suite passes with Turbopack: six tests and five snapshots. - Existing Rust API suite passes its 25 main cases and 15 snapshots in each bundler. Its RSS stabilization stress case fails locally on both this branch and unmodified canary. <!-- NEXT_JS_LLM --> --------- Co-authored-by:Jamiboy Mohammad <jamiboym@gmail.com>
-
Will Binns-Smith authored
## Summary Rename `next-browser-initial-load-optimizer` to `next-bundle-optimizer` and update the skill directory, metadata, links, and install commands. Document how to use the skill with Turbopack's bundle analyzer, with prompts for audits, fixes, and route-specific optimization. ## Verification - Prettier passed for the skill and both guides. - Runtime tests not run (docs and skill rename only). <!-- NEXT_JS_LLM -->
-
Tobias Koppers authored
## What? Task completion now cleans up the task's per-execution state (removing cells that no longer exist, `cleanup_after_execution`) under the same task lock that finishes the execution, before the completion is published (in-progress state removed, `done_event` notified). Previously the cleanup ran afterwards, under a second lock acquisition. A waiter could invalidate the task in that gap and its next execution could start. The old cleanup would then remove that execution's state, e.g. the `outdated_*_dependencies` it was just given, and could also remove cells it had created. ## Why? `collectibles_outdated_dependency` fails locally on canary (5/5 runs here) and passes in CI only by timing. Tracing showed the old cleanup observing the next collector execution already running with populated `outdated_collectibles_dependencies`, then clearing them. Later collectible emissions then made the waiting collector stale, so it executed an extra time. The optimization from #99386 assumes that bookkeeping is intact. There is a second, independent reason the test can see an extra execution: `State::set` invalidates its readers one at a time. The collector can then read the source before the source was invalidated, see the old collectibles, and legitimately re-execute when the new ones arrive. ## How? - `task_execution_completed_cleanup` now takes the held `TaskGuard`. `task_execution_completed_finish` calls it after setting output and immutability, before dropping the guard and notifying `done_event`. The canceled path still cleans up, and stale reschedules (including `verify_determinism` reruns) still skip cleanup, as before. Removed cell data is still dropped outside the critical section. - Tests: - The existing test is unchanged. Its docs now say it is timing-dependent and also covers this cleanup race. - A new gated variant stages the overlap explicitly: the collector waits until the new emitter execution has started, polls its strongly consistent source read to `Pending`, and only then lets the emitter emit. This deterministically covers the dirty-not-stale optimization, independent of `State` invalidation order. ## Verification - With the fix: both tests pass 30/30 locally, and `cargo test -p turbo-tasks-backend` passes. - Mutant (always stale on collectible change): the gated test fails 10/10. - Known limitation: there is no deterministic regression for the cleanup race itself without a backend test hook. With canary's ordering restored, the ungated test failed intermittently, between 0/20 and 8/20 depending on test layout and invocation. The fix was confirmed by tracing and by an experiment that widened the old gap. - Clippy (default and `verify_serialization,print_cache_item_size`), a `verify_determinism` check, and `cargo test -p turbo-tasks-macros-tests` pass. <!-- NEXT_JS_LLM --> <!-- fleet 98a896e8-00fa-4f81-97f0-48bd49e2a9a2 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
-
next-js-bot[bot] authored
-
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 17 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 -->
-