- 25 Sep, 2026 20 commits
-
-
next-js-bot[bot] authored
-
Hendrik Liebau authored
Static root-param tracking for `'use cache'` needs to distinguish which getters a cached module imports. The existing generated module contains every getter, so module-level dependency collection includes unrelated root params. `next/root-params` now re-exports each getter from a separate virtual module. The generated `next/root-params` module declares that it has no side effects, so Turbopack resolves named imports without including unrelated getter modules. Runtime root-param tracking remains unchanged. The split also keeps code hashes stable when unrelated root params are added. The regression test checks this dependency isolation through the existing code-hash manifest.
-
Sebastian "Sebbie" Silbermann authored
Test passes without adapter: https://github.com/vercel/next.js/actions/runs/36130462440/attempts/2 Forked assertions with a clear statement what the intended behavior is would be more helpful. Co-authored-by:
Claude Code (kimi-k3[1m]) <noreply@anthropic.com>
-
Tobias Koppers authored
### What? Limit Turbopack's package-origin project-root tracing to statically named **files**, while resolving the complete original request relative to the package as before. This applies to filesystem, directory, child-process and Node worker references. ### Why? Static does not necessarily mean narrow: `node-gyp-build`'s `path.resolve(dir || '.')` contains a static `'.'` branch. Tracing that from the application root as a directory recursively includes unrelated application assets. We still need packages to find explicitly named application config files. ### How? Analysis records two candidate contexts without inspecting the filesystem: an optional app-root context for static file paths, and a package-local fallback for the original request. At reference resolution, the app-side lookup keeps only fully static file matches; directories and symlinked directories cannot recursively expand there. The package-side lookup independently traces the full pattern, including dynamic alternatives and directory contents. Both results are combined so even a mixed file/directory expression can retain its app config **and** package-local assets; the combination preserves distinct files sharing a request key and deduplicates identical modules. Protobuf `includeDirs` uses the same reference path. Regression fixtures cover a `node-gyp-build`-style `'.'` fallback, mixed file/directory alternatives with same-named files in both contexts, symlinked directories and files, a missing optional config, and Node worker references. The webpack/@vercel/nft path is unchanged. **Verification:** 93 tracing tests and 65 core resolve tests pass; focused Clippy with warnings denied, Rust formatting and diff checks pass. Production next-site size impact has not been independently measured in this fixture. Related: #98628, #98712, #99080. <!-- NEXT_JS_LLM --> <!-- fleet fe000a60-fbb8-4835-b6ef-38d5684822a9 --> --------- 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>
-
next-js-bot[bot] authored
-
Sebastian "Sebbie" Silbermann authored
This produces a new dependency chain which can lead to duplicate Next.js version in monorepo setups. Specifically, the internal sync is broken. It can probably be fixed with some dependency graph doctoring but we need to investigate and document that first. We're close to a stable release and the sync has been blocked all week so getting it back on track has priority. Reverts https://github.com/vercel/next.js/pull/98862
-
Tobias Koppers authored
### What? Stabilizes the Turbopack development test that verifies an invalid dynamic-import target stays unparsed until activation, while checking both server compilation output and the browser-visible error overlay afterward. ### Why? Activating the target can trigger an incidental hard reload as Fast Refresh recovers from the error. A one-shot overlay source read can race that document replacement. The test should check the error it owns without requiring a reload or accepting an absent overlay. ### How? The test retains canary's CLI-output assertion and independently retries a live browser-redbox source assertion filtered to the expected parse-error marker. Playwright re-resolves the locator across document changes; both signals must actually contain the marker. ### Verification - Focused Turbopack dev case under six competing CPU workers: 20/20 passed on rebased canary - Complete `lazy-dynamic-imports` Turbopack dev file: 3/3 passed on rebased canary - Related `next/dynamic` error-overlay case: 10/10 passed on rebased canary - Prettier, ESLint, clean merge-tree, and diff checks <!-- NEXT_JS_LLM --> <!-- fleet 2dd4f041-bfb3-4572-9b57-5cb45a2410cd --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Luke Sandberg authored
When deleting a task, remove the reverse dependeny edges also. Generally this should be empty, but there can be tasks if those tasks are owned by a root that is pinned but not active. So in the rare case that such tasks are 'reactivated' this also dirties the task. This closes a hole where a task with a cell_dependency can reference a deleted task. Then new test demonstrates the bug, without the fix it will panic when collecting the second task
-
Tobias Koppers authored
### What? Replace the Graphite-specific CI optimizer with a **read-only TypeScript gate** for PR stacks formed by ordinary GitHub base/head branch links. This PR includes the work previously reviewed in #99116 and #99122. ### Why? Rebasing a large stack starts expensive `build_and_test` jobs on every PR at once. Let the first three PRs and the top PR run immediately, but defer middle PRs until nearby CI provides a useful signal. A deferred PR must **not** appear mergeable just because its jobs have not started. ### How? - **Find the stack from branch relationships**, not GitHub stack metadata. Middle PRs poll their three nearest predecessors every **five minutes**. Any predecessor with a successful, current-head/current-base `thank you, next` check releases full CI; three unsuccessful results **fail the gate and required aggregate**. While waiting, the gate stays in progress. After five hours without a decision, it releases full CI rather than stranding the PR. - **Revalidate before deciding.** Refresh PR and check data before release/failure so rebases, retargeting and reruns cannot make a stale check decisive. Transient GitHub 5xx/429 errors retry; permanent errors or ambiguous topology start full CI rather than claiming CI passed. - **Keep polling cheap and read-only.** Reuse PR head/base data from `pulls.list` (11 → **8 REST reads** per ordinary waiting poll), while still checking *all three* predecessors. The bundled action is checked out at the current test-merge `${{ github.sha }}` without persisted credentials; forks bypass the checkout/gate and run full CI. The six-hour gate stays on `ubuntu-latest` because `ubuntu-slim` has a 15-minute limit. <details> <summary>Implementation and review tradeoffs</summary> - The local action bundles a pinned Octokit. Isolated Jest tests use fake timers and a real check-run response fixture. CI runs the existing Next.js lint/examples/externals/browser checks before action-specific install, typecheck, build and Jest; a generated-diff guard catches stale bundles. - `uses: ./...` requires action files already in the job workspace; it does not fetch them like `owner/repo@ref`. The sparse checkout fetches only `action.yml` and `dist/index.js`. Caller and reusable workflow grant read-only `checks`, `contents` and `pull-requests` permissions; the gate inherits no secrets. - Cheap-check graph splitting was deliberately deferred. Job-level concurrency does not enforce predecessor *success*; stopping at the first pending predecessor misses an older success. GraphQL batching needs a verified check-association projection and measured cost before replacing the current REST lookup. - When the child commits became reachable from this branch, GitHub automatically marked #99116 and #99122 merged; no PR merge operation was used. [Action README](https://github.com/vercel/next.js/blob/ci/branch-stack-polling-gate/.github/actions/pr-stack-ci-gate/README.md) documents the contract. </details> ### Verification - **Focused checks:** TypeScript, Prettier, deterministic bundle/diff checks and **24/24 Jest** passed. The final comment-only change in `src/gate.ts` produced a byte-identical bundle. The [current root run](https://github.com/vercel/next.js/actions/runs/35967795126) passed its gate, lint and required `thank you, next` on **attempt 2** (same SHA); attempt 1 failed an intermittent redbox test. - **Live six-PR test on the compiled action:** the first three and top passed the gate immediately. Middle #99097 and #99098 **waited**. On initial attempts, both **failed closed** when their three predecessors were unsuccessful, with no expensive jobs started. On rerun, #99097 **released on #99086's success** despite #99096 failing and #99095 still pending; full CI ran but failed unrelated tests. #99098 waited for *its own* three predecessors, then failed closed again. Gate release never marked full CI successful. - **Known limitation:** product-test failures—not the gate—left four immediate/released PRs with failed full CI on various attempts. All five test drafts remain open for reuse. Workflow reruns in this experiment were initiated externally; this agent's GitHub integration received 403 (`actions=write` required) when attempting a rerun. <details> <summary>Current compiled-action six-PR results, with workflow and gate logs (2026-09-24)</summary> Each draft is one Jest assertion commit over its signed parent; the cumulative focused suite passes **24/24**. Times below are UTC. “Required” refers to `thank you, next`, not the gate check. | Position | PR / signed head / workflow | Gate outcome | Required check | Expensive work | | :-- | :-- | :-- | :-- | :-- | | 1 | [#99086](https://github.com/vercel/next.js/actions/runs/35967795126) `85444c9e` | immediate pass | failed attempt 1; **passed attempt 2** | ran twice | | 2 | [#99095](https://github.com/vercel/next.js/actions/runs/35969902709) `bc19787a` | immediate pass | failed attempts 1 and 2 | ran twice | | 3 | [#99096](https://github.com/vercel/next.js/actions/runs/35970016367) `98bfab58` | immediate pass | failed | ran | | 4 | [#99097](https://github.com/vercel/next.js/actions/runs/35970109573) `e260bf96` | [attempt 1](https://github.com/vercel/next.js/actions/runs/35970109573/job/107537584401): waited → failed 08:02; [attempt 2](https://github.com/vercel/next.js/actions/runs/35970109573/job/107609256427): **released 11:19** | failed both attempts (attempt 2: product tests) | none on attempt 1; full CI ran on attempt 2 | | 5 | [#99098](https://github.com/vercel/next.js/actions/runs/35970206069) `01222d4a` | [attempt 1](https://github.com/vercel/next.js/actions/runs/35970206069/job/107537887530): waited → failed 08:03; [attempt 2](https://github.com/vercel/next.js/actions/runs/35970206069/job/107609367420): waited → failed 11:50 | failed both attempts | **never started** | | 6 (top) | [#99099](https://github.com/vercel/next.js/actions/runs/35970312588) `c6f3cf4a` | immediate pass | failed attempts 1 and 2 | ran twice | **Decision evidence:** On attempt 1, #99097 saw #99096/#99095/#99086 all unsuccessful, and #99098 saw #99097/#99096/#99095 all unsuccessful; their required checks failed and downstream jobs were skipped *because their gates failed*. After #99086's successful rerun, #99097 attempt 2 logged `#99096=unsuccessful, #99095=waiting, #99086=success`; its gate passed and [build-next actually ran and passed](https://github.com/vercel/next.js/actions/runs/35970109573/job/107609336752). #99098 could not use #99086 (outside its nearest-three window); it failed at 11:50 when #99097/#99096/#99095 had all finished without success. Completed failed gates do not restart automatically when a predecessor reruns. </details> <details> <summary>Unrelated CI failures and recovered flaky tests</summary> - #99086's attempt 1 failed `lazy-dynamic-imports › does not parse a dynamic import target before activation`: redbox source was `null` after all in-job retries ([job](https://github.com/vercel/next.js/actions/runs/35967795126/job/107530613870)). **The same-head workflow passed on attempt 2.** - #99095, #99096, #99097 attempt 2 and #99099 failed `instant-insights-tab-overlay › should wrap the mobile overlay header only when it does not fit`: observed header top difference **24**, expected **< 4**, after in-job retries ([example job](https://github.com/vercel/next.js/actions/runs/35969902709/job/107537341995)). #99096 also failed `turbopack-loader-file-dependencies › should update when a build dependency changes` (`build-one` instead of `build-two`, [job](https://github.com/vercel/next.js/actions/runs/35970016367/job/107537932737)). #99097 attempt 2 additionally failed the `lazy-dynamic-imports` redbox assertion in an experimental cache-components shard ([job](https://github.com/vercel/next.js/actions/runs/35970109573/job/107609732882)). These failures are not gate-test failures. - **Recovered in-job flakes:** #99096 `instant-validation/head-and-reporting › invalid - runtime prefetch - dynamic viewport blocks navigation` (redbox did not open; passed retry 1/2); #99095 `use-cache-without-experimental-flag › should recover from the build error if useCache flag is set` (Playwright execution context destroyed on navigation; passed retry 1/2); #99097 attempt 2 `lazy-dynamic-imports` in a different Turbopack-dev shard (passed retry 2/2), `instant-validation/suspense-boundaries` (redbox did not open; passed retry 2/2), and `instant-validation/head-and-reporting.partial-prefetching` (redbox did not open; passed retry 1/2). </details> <details> <summary>Earlier implementation smoke tests and CJS-gate stack runs</summary> - The [folded-code root head `89f0ca34` full run](https://github.com/vercel/next.js/actions/runs/35965443069) passed gate, build, lint (including **24/24 Jest**) and required `thank you, next`. The earlier [compiled-action child head `25647f00` run](https://github.com/vercel/next.js/actions/runs/35922700289) also passed full CI, proving same-SHA sparse checkout before the lint-order follow-up was folded into root. - **CJS-gate fail-closed run (base `ec0abf41`, 2026-09-23):** [#99086](https://github.com/vercel/next.js/actions/runs/35875541530), [#99095](https://github.com/vercel/next.js/actions/runs/35875598833), [#99096](https://github.com/vercel/next.js/actions/runs/35875651890) and top [#99099](https://github.com/vercel/next.js/actions/runs/35875952426) ran full CI and failed unrelated tests. Middle [#99097](https://github.com/vercel/next.js/actions/runs/35875701404/job/107231099534) failed its gate at 15:20 and [#99098](https://github.com/vercel/next.js/actions/runs/35875873698/job/107231827956) at 15:21; required checks failed and expensive jobs never started. A Turbopack source-map snapshot failure was subsequently fixed in [#99106](https://github.com/vercel/next.js/pull/99106). - **CJS-gate release run (base `8ff7f2bd`, 2026-09-23):** [#99086](https://github.com/vercel/next.js/actions/runs/35887913444) and [#99095](https://github.com/vercel/next.js/actions/runs/35887957948) passed full CI. [#99097](https://github.com/vercel/next.js/actions/runs/35888074168/job/107273254039) and [#99098](https://github.com/vercel/next.js/actions/runs/35888146874/job/107273514756) waited, then released at the next poll on #99095's green check while a nearer predecessor was unresolved. Their later full CI failed; top [#99099](https://github.com/vercel/next.js/actions/runs/35888202575) started immediately (later canceled). These precede the TypeScript action and are not claimed as evidence for its current head. </details> <!-- NEXT_JS_LLM --> <!-- fleet d2ae64f1-7106-4ba4-b88a-7785c19904c6 --> --------- 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>
-
Andrew Clark authored
The prefetch scheduler's static walk decided at the parent which child was still part of the current page and which began the new part of the route, and it fetched the head through two functions of its own that copied the per-segment decision (a static attempt, then a runtime deopt if that wasn't enough) for a node that hangs off the route root instead of sitting in the tree. Give the walk the same shape as the navigation's. The walk over the part of the route the current page also has owns the comparison for its own node — first whether the route position still matches, then whether any of its params changed — and hands off to the walk over the new part of the route when either fails, so the root enters the shared walk like every other node. The per-segment decision, a static attempt or a runtime deopt, lives in one function that the new-part walk calls for every segment, and the runtime request's walk gets the same split between iterating the children and deciding for one node. The head is a one-node route tree like any other segment now, so it goes through the same functions: the new-part static walk and the direct runtime fetch it already had. This is a pure restructuring and issues the same requests as before: a segment the navigation keeps is still prefetched at the ordinary static tier without a runtime deopt, the head is still fetched whenever anything is, and a chain of inlined segments is still dropped where a Shell-phase walk crosses from a kept node into the new part. A later change uses the shape to prefetch only what the navigation would fetch.
-
Andrew Clark authored
Changing a page’s search params doesn’t change which page it is, but it may change the data that page needs. The router currently mixes these concerns by appending search params to `__PAGE__` segments. Remove that encoding so we can compare which route is being rendered separately from the param values used to render it. Param values are now compared through the existing VaryPath data structure, while route structure is compared during the existing tree traversals. Each traversal can decide which comparisons matter for the work it’s doing. Client-side comparisons and history restoration still need the search params, so store them in a separate FlightRouterState slot for now. As before, previous-page search params are stripped from normal request headers. This is a temporary step that lets us migrate incrementally. Eventually, FlightRouterState will be replaced by a type that represents the route and its params more directly. This is mostly a refactor, though it fixes an accidental inconsistency in search-param handling compared with regular route params, avoiding some redundant prefetch work. Fully cached pages already track their vary params correctly. This separation prepares us to do the same for partially dynamic segments during navigation, so changing an unrelated param won’t require rendering their dynamic content again.
-
Andrew Clark authored
Throughout most of the client router implementation, the head is treated as if it belongs to the page segment. For example, CacheNode has separate `rsc` and `headRsc` fields, and the page's CacheNode owns both. This had led to a bunch of special cases related to the head. The Segment Cache largely (though not entirely) avoids this by instead modeling the head as a special kind of segment. It has its own vary path, its own SegmentCacheEntry, etc. There are still a few places where treatment of the head is special, because it doesn't exist inside the normal route tree structure. But we treat it like segment wherever possible. This PR updates the navigation implementation to use the same model: treat the head as a segment that is a sibling to the route segment tree. This is a large diff but the changes are almost entirely mechanical. Although the added/removed balance is about even, that includes a new test case. The net number of implementation lines has gone down.
-
Andrew Clark authored
Adds a `varyParams` field to CacheNode. When present, they represent the set of params that the data for that segment varies by. (When null, the set is unknown.) Currently, the vary params are only known when the data is fully cached; vary params are not recorded during a dynamic render. However, this will change in a future PR once we've integrated with the experimental Ledgers feature in React.
-
Andrew Clark authored
Refactors the CacheNode tree to use the RouteTree<T> data type. CacheNode used to be a tree-shaped object, with a similar structure to RouteTree<T>. CacheNode is now a data container instead, embedded inside a RouteTree structure. So the usage sites change from CacheNode to RouteTree<CacheNode>. As a result, we can now diff against the render tree directly during prefetches and navigations, instead of diffing against FlightRouterState. This gets us closer to migrating everything away from FlightRouterState to our shared data types.
-
Andrew Clark authored
Part of a series of internal refactors to improve param tracking on the client. A route tree node used to come in two variants, a layout and a page, distinguished by an isPage flag that every constructor had to keep consistent with the VaryPath it built. The variants only differed in whether the vary path carried a search params entry, and the code that needed to know either checked the flag or read the vary path's shape positionally. Collapse them into one RouteTree type with one VaryPath type. The few places that still care whether a node is a page derive it from the segment. When something needs to read the search params, they can be accessed from the RouteTree or VaryPath like we do for other params. This is a pure refactor of the existing code. It reads more naturally with a single tree type and a single vary path type, which the rest of this stack builds on.
-
Luke Sandberg authored
Fix the definition of GC roots to account for all transient references There was a categorical mistake in how `uppers` and `collectible_dependents` were interpreted. Both of these refer to a task above us and this is it is a reference but the reference might be comming from transient or persistent tasks. This is what kept confusing the 'root' definition So the new definition is simply * You are collectible if there are no references (persistent or transient) * You are a root if there are only transient references, which includes transient uppers and collectible_dependents The old definition expected roots to have no uppers at all, which isn't correct. A `run_once` task becomes an aggregation root and so the nested persistent tasks reference it as an upper. Those tasks should become gc roots since they are on the transient <--> persistent boundary and the only thing retaining them is references from transient tasks.
-
Luke Sandberg authored
## What When removing edges, only enqueue `lost follower` jobs when we actually remove children. ## Why GC can race with other kinds of task completion which also remove outgoing edges. If task completion drops a child from a task that also becomes collectible. Then it is possible for there to be an enqueued CleanupOldEdges job at the time GC runs. Then we will have two jobs that remove children, only one will succeed but both will enqueue `InnerOfUppersLostFollowersJob` for all the chidren. This can lead to panics since one of those jobs will fail to remove the follower The fix is simple, only remove tasks as followers when you actually removed them as children.
-
Luke Sandberg authored
Fix refcounting for transient tasks - ensure transient tasks refcount each other correctly, and are eligible for collection - ensure root tasks are born with a transient_ref_count of 1 Also drop some ultimately harmful conditions from the gc predicate - don't consider `cell_dependent`. cell dependencies form cycles and are subsumed by ancestors - to read a cell you have to read it from a child (covered by parent_count) or be passed it from a parent. For the parent to have passed it to you it must have a child dependency on the producer or be passed it by its parent (recursively). So the task that passed you the vc must be holding ownership over both tasks. - therefore a stale cell_dependency can only exist within a task that is effectively dead, however because we do not reliably clean up all tasks in a session (due to leaking root tasks), we cannot fully exclude the existence of stale cell_dependency edges. We just know they must only exist within unreachable tasks. --------- Co-authored-by:Claude Opus 5 (1M context) <noreply@anthropic.com>
-
Luke Sandberg authored
Make invalidating deleted tasks a no-op. Invalidators now represent a 'weak' reference to a task, and invalidations don't assert task existence. We know that the task exists when the invalidator is created but by the time an invalidation occurs it might not exist anymore. So treat the dependency as weak. Take care to not create 'blank' tasks when querying for them, this can confuse assertions that occur later. ## Why is this safe? Currently it is safe because we never reuse task ids, so invalidating a deleted task is perfectly reasonable, much like invalidating a non-active task, there is nothing to do In the future if we start reusing task ids, then this becomes an ABA problem. An invalidator can point at a new task. This is also not too bad, a spurious invalidation is self healing. Also most invalidators are not actually persisted which limits the risk. So we can either decide to build a mechanism to tear down these stale edges or tolerate spurious invalidations. I think we could make invalidator users subscribe to a 'deleted task id bus' which would allow them to drop references, this could be useful and then the few cases where we _persist_ invalidators (by way of `State` objects) would need to devise a new mechanism (or decide to tolerate the spurious invalidations) --------- Co-authored-by:
Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by:
vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
-
Josh Story authored
## Summary Avoid decoding route parameters a second time while selecting prerender metadata. This fixes valid percent-containing URLs returning 500, including both build-generated closed routes and runtime-generated open routes. For example, a request for `/open/docs/space%20here/with%2Fslash/fallback%25` is already normalized for manifest lookup before reaching `PrerenderManifestMatcher`. Its final parameter now contains a literal `%`. The matcher previously used `getRouteMatcher`, which tried to decode the captures again and threw even though this call only needed to determine whether the route structure matched. Test the existing, lazily constructed route regular expression directly instead. Matcher precedence, source-page filtering, and the current server parameter encoding behavior stay unchanged. This does not introduce a new manifest or adapter contract. The open fallback is requested twice to cover generation and reuse. The existing fixture uses `dynamicParams = false` and remains excluded from the Cache Components matrix, which does not support that configuration. This is an independent prerequisite for #97393: the failure reproduces without the parameter-matching API and should be fixed for existing apps too. ## Verification - Before the fix, the new closed and open catch-all requests returned 500 with a parameter-decoding error. After the fix, both return 200 and retain the existing encoded server parameter values. - The focused matcher unit suite passes all six tests. - The three encoding regressions pass with production Webpack after restacking. The API routing suite also passes all 36 tests with fresh-native production Turbopack above this prerequisite, including its existing percent-containing URL cases. - The earlier isolated verification passed package TypeScript and changed-file lint. Deployment verification remains for CI. <!-- NEXT_JS_LLM -->
-
- 24 Sep, 2026 20 commits
-
-
next-js-bot[bot] authored
-
Sebastian "Sebbie" Silbermann authored
The `test-e2e-deploy-release` run for `v16.4.0-canary.43` failed three webpack shards deterministically ([run](https://github.com/vercel/next.js/actions/runs/35989345663)) after #98847 and #98848 removed the deploy-mode exclusions. On PRs we only run deploy tests for Turbopack so these failures were missed. - `use-cache-segment-configs`: #98847 added a deploy-specific snapshot for Turbopack, but the webpack path still used the local snapshot. Vercel's fetched build logs strip code-frame indentation and trailing whitespace, so the deployed output can never match it. The webpack assertion now has its own deploy branch with the exact formatting Vercel produces. - `app-edge-invalid-reexport`: #98848 removed `skipDeployment`, but the fixture exports `preferredRegion = 'test-region'`, which the Vercel platform rejects during deployment (`Invalid region: test-region`). The test now overrides the basic page with a valid region (`iad1`) in deploy mode. The asserted re-export warnings are build-time diagnostics, so the region value does not affect them. - `deprecation-warnings`: both tests call `next.start()` inside the test body, which `e2e-utils` caps at 60 seconds when no explicit timeout is given. Deployments now take about two minutes (`Ready in 2m`, up from `Ready in 1m` in the passing canary.42 run with the same Vercel CLI 59.26.0), so both tests time out on every run. They now pass an explicit 240-second timeout, matching the other deploy tests. --------- Co-authored-by:
Claude Code (kimi-k3[1m]) <noreply@anthropic.com>
-
Jiwon Choi authored
Same-major security and latest updates received migration instructions that could send agents through unnecessary codemods and Pages Router work. Therefore split the docs and provide only the relevant context.
-
Benjamin Woodruff authored
Follow-up to #98003 so that this works with `vc deploy` (or anything else using the adapters API, this isn't a breaking change). Creates "synthetic" symlinks when it needs to rewrite a symlink target (for cross-root links). Potential follow-up: We can potentially extend the adapter API to let us pass the full symlink information to adapters that support it, so that we don't have to create a bunch of synthetic symlink files on disk.
-
Jiwon Choi authored
sonnet reaches context max right after handoff, will follow up reducing the context for same major
-
Joseph authored
Derived from the conversation over at: https://github.com/vercel/next.js/discussions/99025 I think `preload` needs that additional caveat. Document the declaration of a font-family. Note that the pattern discussed on that thread is not something we should document, at least I don't think so, I am just expanding the docs on this area.
-
next-js-bot[bot] authored
-
Tobias Koppers authored
### What? Stops Turbopack from re-chunking every App Router layout segment once per page in production builds. The manually constructed server-utilities chunk group is now only created in development. ### Why? A production build should chunk each shared layout segment exactly once. Instead, a layout segment was chunked again for every endpoint below it. On a small app with four endpoints, the root layout was chunked 4 times and a nested `dashboard` layout 2 times. The emitted output was still shared, so this was wasted build work rather than bigger bundles, which is why output-based tests never caught it. Production already builds a single module graph for the whole app, so the module graph is not what differs between endpoints. The difference comes from the server-utilities chunk group that seeds the layout-segment chain: - It is a `SharedMerged` group whose parent is the current endpoint's entry chunk group. - A merged group's parent is part of its identity, so every endpoint gets a different group (5 chunkings on the same app). - Its result seeds the availability info passed to each layout segment after it. Availability info is part of the chunking task key, so each shared segment ended up with a different key per endpoint and was chunked again. The code comment already said this manual shared chunk exists mainly to help development. That makes sense there: each endpoint has its own module graph in development, and without the group layout segments would share very little across pages. This is PR 0 of the chunk-group stack. The PRs above it are: 1. #98733 — canonical chunk-group identity 2. #98734 — graph-derived output groups 3. #98823 — Pages Router dev client graph chaining 4. #98685 — chunk-group availability bitmaps 5. #99050 — keyed chunk-group index lookups ### How? The manual server-utilities group is now created only in per-page-module-graph mode, which is development. In production the layout-segment chain starts from an endpoint-independent state, so sibling endpoints produce the same chunking task key for a shared segment. The server utilities are then chunked with the entry through the whole-app graph. Development behaves exactly as before. On the same four-endpoint app, a production build now chunks the root layout and the nested layout **once each**, and the manual server-utilities group is gone. Development still creates the group and chunks segments per page, which is expected for on-demand compilation. Adds `test/e2e/app-dir/layout-segment-chunk-sharing`, a root layout and a nested layout that share one module across two sibling pages. It asserts two things: - **Output sharing (Turbopack dev and production):** the shared module is emitted into exactly one server chunk. Webpack builds a self-contained server bundle per route, so this assertion is gated on the bundler, not the mode. - **Work sharing (Turbopack production only):** output sharing alone does not prove the chunking *task* was reused, since a segment could be re-chunked per page with an identical result. The test builds with tracing enabled and uses `next internal query-trace` to count executions of the nested layout's chunking task, which must be exactly one. A cache hit produces no execution span, so the count equals the number of real executions. Development compiles pages on demand with a module graph per page, so repeated chunking is expected there and the assertion is skipped. With the fix reverted, the work-sharing assertion fails with 2 executions, while the output-sharing assertion still passes. ### Performance Measured on a synthetic App Router app: a root layout and a nested `section/layout.tsx`, each importing M modules (~20% `'use client'`), with N trivial sibling pages under `section/`. Cold `next build` with release native builds of both commits (`192fcaf7` vs this PR, one shared JS build); paired runs in ABBA order on an 8 vCPU / 16 GB Vercel Sandbox VM; 95% Student-t intervals on the paired differences. At **800 pages × 1,000 modules per layout**, a dedicated 12-pair run: | metric | Δ | 95% CI | pairs improved | |---|---|---|---| | Turbopack compile time | **−6.3%** (−767 ms) | [−968, −565] ms | 12/12 | | total `next build` time | **−2.2%** (−764 ms) | [−1241, −287] ms | 9/12 | | Turbopack process peak RSS | **−4.2%** (−104 MB) | [−141, −68] MB | 12/12 | In traces of that build, the nested layout goes from 800 chunking executions to 1, the root layout from 802 to 1, and the server-utilities group from 803 to 0 (Node.js chunking spans overall: 7,223 → 1,617). Smaller configurations (50–800 pages × 200 modules, 200 pages × 1,000 modules; 8 pairs each) showed no detected difference in time or Turbopack memory, so the gain matters mainly for large apps. **Trade-off:** without the manual shared group, a few server utilities (the `*-async-storage.external` and `runtime-reacts.external` wrappers, the vendored `react-rsc` getter and a small `bytes` helper) are now inlined into each page's SSR entry chunk instead of being emitted once. That adds about **2.3 KB of server output per App Router endpoint** (+0.9% to +4.4% of server JS in these fixtures). Client JS is byte-identical. Keeping these modules shared in production without per-endpoint identity would be a possible follow-up. ### Verification - Trace measurement on the fixture (production): root layout 4 → 1, nested layout 2 → 1, server-utilities group 5 → 0; dev unchanged - Production build renders and serves every route with the shared module; the shared module is still emitted into exactly one server chunk - `layout-segment-chunk-sharing` — Turbopack production (3 passed), Turbopack dev (output assertion passed, trace assertion skipped), webpack production (Turbopack-only assertions skipped) - `cargo clippy --workspace --all-targets -- -D warnings -A deprecated`, `cargo fmt --all -- --check` - `turbopack-core` + `next-core` unit tests (252 passed); `turbopack-tests` snapshots (126 passed, no changes) <!-- NEXT_JS_LLM --> <!-- fleet 4f67c6f7-bbe2-454b-9a17-822a60ef8f7e --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Will Binns-Smith authored
## Summary Exclude traced project files from emitted output-type classification in the bundle analyzer. Traced TypeScript sources are synthetic provenance entries, but were classified as assets because their filenames do not use an emitted JavaScript extension. This could make JavaScript sources appear red in the treemap even when their emitted chunks are JavaScript. ## Verification - `pnpm --filter=@next/bundle-analyzer-ui build` <!-- NEXT_JS_LLM -->
-
Luke Sandberg authored
Fix AggregationGraph updates during GC. During GC we aremoving a lot of edges so this can trigger a lot of aggregation graph churn. Because of the highly parallel nature of GC this can end up with multiple queues fighting over updates which can exceed various retry limits and lead to things like trying to turn nodes into `followers` that are actively being deleted. Instead we just don't rebalance the aggregation graph during GC, instead we buffer every `rebalance` request and set the `optimize` budget to zero. Then after GC settles we process all the rebalances at once, taking care to filter out any tasks that have been since deleted. Because GC is only removing edges it can lead to inefficient graphs (too many interior nodes) but not violate graph invariants. Alternatives considered: The initial idea was to ensure GC had finished with all 'children' of the node before processing rebalance requests, but this was only a partial solution (and complex!), since it didn't handle the case of an aggregating node having multiple children become collectible in the initial scan, this could still trigger 'optimization contention' and turning dead nodes into followers. Testing: The test/benchmark are enhanced to produce non-trivial aggregation graphs which improves test coverage (though the issue of racing deletes was trivially found by CI also) --------- Co-authored-by:Claude Opus 5 (1M context) <noreply@anthropic.com>
-
Jiwon Choi authored
The ESLint migration currently changes lint configuration and dependencies even when no package script uses `next lint`. Projects using another linter or ESLint directly should keep their existing setup. Also, pin to v9 at max because plugins used by `eslint-config-next` depended on v9
-
Niklas Mischkulnig authored
These were only ever `StyledString::Text` anyway. So just store the RcStr directly Simplify the code to fix these lint errors ``` ➜ next.js-other git:(canary) ✗ pnpm sg scan error[no-map-async-cell]: Using `.map(async |...| { ...cell() })` causes non-deterministic cell order ┌─ turbopack/crates/turbopack-core/src/module_graph/mod.rs:766:33 │ 722 │ ╭ modules 723 │ │ .iter() 724 │ │ .map(async |m| { │ │ ╭──────────────────────' · │ │ 766 │ │ │ Vc::cell(rcstr!("Module graph is missing an entry point")), │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ · │ │ 798 │ │ │ }) │ ╰─│──────────────────' │ ╰─────────────────' │ = You probably want to first try_join() the async computations before wrapping them in a cell. error[no-map-async-cell]: Using `.map(async |...| { ...cell() })` causes non-deterministic cell order ┌─ turbopack/crates/turbopack-core/src/module_graph/mod.rs:767:33 │ 722 │ ╭ modules 723 │ │ .iter() 724 │ │ .map(async |m| { │ │ ╭──────────────────────' · │ │ 767 │ ╭ │ │ StyledString::Text(rcstr!( · │ │ │ 771 │ │ │ │ .cell(), │ ╰─│─│───────────────────────────────────────^ · │ │ 798 │ │ │ }) │ ╰─│──────────────────' │ ╰─────────────────' │ = You probably want to first try_join() the async computations before wrapping them in a cell. Error: 2 error(s) found in code. Help: Scan succeeded and found error level diagnostics in the codebase. ➜ next.js-other git:(canary) ✗ ``` -
Tobias Koppers authored
### What? Generate **both RSC client-reference proxies and WebAssembly loaders** under their graph-backed wrapper module identities, using one shared, higher-level content helper. Remove both generated-path exceptions from `BindingUsageInfo::used_exports` and the earlier proxy-specific export filter. ### Why? The wrapper is the module in Turbopack's graph, but its chunk item previously delegated code generation to a separately processed virtual JS module. Export-usage lookup for that proxy/loader missed the graph and fell back to “all exports used.” In a `sideEffects: false` barrel this could register a pruned client export and request a missing `<locals>` module ID. The WebAssembly loader had the same graph-identity mismatch, hidden by a separate filename-based fallback. Canary's #99102 now guards against the client-reference missing-ID symptom by checking pruned references. This PR fixes the upstream identity mismatch instead so `expand_exports()` sees real usage; #99102's independent safety checks remain in place. ### How? `chunk_item_content_with_code_from(graph_module, code_source, ...)` takes the generated source's analyzed program, references, exports, source map and async behavior while using the wrapper for the *whole code-generation module context*. Both client-reference and WASM wrappers call it. This replaces the public low-level `with_module_context` setter; it does not change module IDs, WASM output assets, React Flight registration, or the existing single-chunk WASM rejection. sokra's `ResolvedVc` suggestions are also applied. #99090's pruned-reexport-source guard remains necessary: removing it independently still fails its execution fixture. #99082 proposed reverting all of #98617 and closed unmerged; it was not a separate fix to delete. The neutral production proxy regression and two supplemental pruned-source execution fixtures remain in the PR. ### Verification - **WASM can-fail/can-pass:** all 3 existing WASM execution fixtures pass before removing the fallback; with the fallback removed but old loader delegation retained, all 3 fail `export usage not found ...wasm_.loader.mjs`; with the shared helper, all 3 pass (instantiation, imported functions/memory, and `?module` compilation). - **Proxy can-fail/can-pass:** without the wrapper-context path and proxy fallback, the production fixture fails `export usage not found .../__nextjs-internal-proxy.mjs`; with the fix it passes. - **Rust/build:** 1,282 tests pass across affected crates; clippy (`-D warnings`), rustfmt and `pnpm build-all` (18/18 tasks) pass. - **Next.js integration:** Turbopack production 6 suites/12 tests (proxy, used client references, #99102 regression, edge WASM and WASM output tracing); development 3 suites/8 tests (proxy, used client references and edge WASM). Client-reference chunking 1/1. After rebasing onto current canary, `pnpm build-all` and focused proxy/edge WASM production tests (3 suites/7 tests) pass again. <!-- NEXT_JS_LLM --> <!-- fleet ecdfa248-cd54-41ac-b4a2-c9d49e2a67ee --> --------- 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>
-
Janka Uryga authored
Adjusts Instant Validation internals to validate the `ShellStatic` stage instead of `ShellRuntime` when `ensureStatic >= "shell"`. If that's the case, the client will do a static request (and extract the shell from it), so the app shell cannot access session data (unlike the PPF default, where we use a runtime shell). Note that in some cases, this might seem more restrictive than needed. For `ensureStatic >= "shell"`, the client will do a static prefetch that goes up to the `Static` stage which resolves more things, like static `params`, `prefetch()` ( in the `PrefetchStatic` stage) and `navigation()` (in the `NavigationStatic` stage). However: 1. The client expects to be able to rewind the static prefetch into a shell and reuse it across the whole route, so we should be validating that the shell is actually useful. 2. For `ensureStatic = "shell"`, we might still do a *runtime* prefetch (with `<Link prefetch={true}>`), which will not have `navigation()`, and validating `ShellStatic` catches that. ### Implementation notes - I've renamed `RequestStore.needsAppShell` to `RequestStore.needsRuntimeShell` (undoing a previous rename), because the `ShellStatic` stage can _also_ be an App Shell, just not a _runtime_ one. The flag controls whether or not we're delaying link data until the runtime stages, which we don't need to do if the shell is static. - If we have `ensureStatic >= "shell"` set, we _won't_ set `RequestStore.needsRuntimeShell` anymore, which means that the main render can once again be re-used for both IV and SSV. `prepareValidationInputsInPartialPrefetching` is changed accordingly. We'll also set `revealAfterStage` to `StaticShell` to match what the client would have prefetched. - We add a new mode in instant validation, `ValidationPrefetchKind.StaticAppShell`, which checks the prefetch at the `ShellStatic` stage. This is enabled if we have `ensureStatic >= "shell"`. the PPF default mode`ValidationPrefetchKind.RuntimeAppShell` uses `ShellRuntime` instead. ### Tests - IV should show an insight for unguarded `cookies()` if `ensureStatic >= "shell"` (unlike the default behavior of app shells) - IV should *still* show an insight for unguarded static `params`, `prefetch()`, and `navigation()` regardless of `ensureStatic` (same as default) -
Jimmy Miller authored
Test was flaking on grabbing redbox error message. In my testing grabbing the cli output instead got rid of the flakes.
-
Sebastian "Sebbie" Silbermann authored
Skips the tests that flaked during deploy in the `test-e2e-deploy-release` run for `v16.4.0-canary.41` ([run 35935267084, attempt 2](https://github.com/vercel/next.js/actions/runs/35935267084/attempts/2)), using `// @force-gate !deploy` so they keep running in dev and start CI: - `parallel-routes-and-interception`: `should support parallel route tab bars` (Webpack 2/8 and Turbopack 1/12), `should throw a 404 when no matching parallel route is found` (Turbopack 1/12), `should handle a loading state` (Webpack 2/8) - `prefetch-static-shell`: `[FAILING] speculative: attempts a static prefetch and does not fall back to a runtime prefetch` (Webpack 8/8) - `prefetch-fallback-static`: 6 cases under `when the param was not prerendered and an ISR fallback was served` (Adapter Turbopack 8/12; the 2 sibling cases that passed stay ungated)
-
Sebastian "Sebbie" Silbermann authored
A rerun or new run on the same commit currently reuploads and overwrites the tarballs. Mostly to accomodate full runs on a commit to get all the binaries (regular runs only build for Linux). Instead, we'll soon return a 409 from the server so that a tarball can be served as immutable. This PR makes the client resilient against 409s. If we ever build different variants for the same commit, we should update the route instead to reflect different build variants. This is would be the better choice anyway so that you know what build variant is behind a commit. Co-authored-by:Claude Code (kimi-k3[1m]) <noreply@anthropic.com>
-
next-js-bot[bot] authored
-
Tobias Koppers authored
### What? Tune production Node.js server JavaScript chunking to use a lower estimated cost for loading a chunk, a smaller soft minimum chunk size, and no per-group chunk-count target. Client, CSS, Edge, and development chunking remain unchanged. ### Why? Server chunks are loaded with Node.js `require()`, not network requests. Measurements across synthetic JavaScript chunks found roughly 0.1 ms of fixed load overhead, equivalent to approximately 2.5–25 KB of parsing work depending on code density. The existing 200 KB estimate overweights each server-side load and encourages unnecessary merging. ### How? Apply the server-specific tuning to both Node production chunking contexts while keeping the existing maximum merge size. The values are an initial estimate from the benchmark; representative application builds and cold-start measurements can refine them. ### Verification - `cargo fmt --manifest-path crates/next-core/Cargo.toml -- --check` — passed. - `git diff --check` and checks of both Node contexts and unchanged Edge values — passed. - `cargo check -p next-core --offline` — blocked before compilation by an uncached `bgw/bincode` Git dependency. <!-- NEXT_JS_LLM --> <!-- fleet 8b0bc78c-72fb-424d-a85e-c5a5b87ff5f4 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Niklas Mischkulnig authored
Regression from #98617
-