- 02 Jul, 2026 25 commits
-
-
next-js-bot[bot] authored
-
dan authored
Alternative to https://github.com/vercel/next.js/pull/95188. Fixes https://github.com/vercel/next.js/issues/86151#issuecomment-4802297986. This fixes a bug where a navigation would spuriously get reverted once a Server Action settles. ## Test Plan New e2e tests that fail before the fix and pass after the fix. I've steered the agent to cover both the broken case now *and* the case that the regressing PR (#82674) was originally trying to fix. The test itself is reduced from https://github.com/vercel/next.js/pull/95188. Also, verified before/after in a real tiny app based on the tests. Before the fix, it reverts to the previous route; after the fix, it stays on the last route as it should. The tests themselves are a bit wonky and do some timing assertions. I had no luck reducing them further. ## Summary *Note: Everything below is written by Fable.* Fixes a regression where a navigation could get reverted shortly after it committed if a Server Action was still in flight when the navigation started: the destination page renders, then the router snaps back to the previous URL. Regressed in 15.5.1 via #82674. Reported in #86151, with a repro and initial investigation by @errmakov in #95188. ### Why? When a navigation starts while a Server Action is in flight, the router discards the action and the navigation takes its place at the head of the action queue. The discarded action still runs to completion. Since #82674, its completion also called `runRemainingActions`, which advances the queue — but the discarded action is no longer at the head of the queue, the navigation is. This started the next queued action while the navigation was still running, computed against router state that didn't include the navigation yet. Those actions send their requests with the previous URL, and applying their responses reverts the navigation. The promise rejection path had the same problem even before #82674: a discarded action that rejected would also advance the queue. ### How? Only the settlement of the action at the head of the queue may advance the queue. A discarded action's settlement (resolve or reject) now only records whether the action revalidated, and the deferred refresh is flushed once the queue goes idle. This keeps the behavior #82674 was after: no refresh for discarded actions that didn't revalidate, and a refresh for those that did — including when they settle mid-navigation, a case that could previously lose the refresh entirely. --------- Co-authored-by:
errmakov <ide404@gmail.com>
-
Hendrik Liebau authored
Overriding the `default` `cacheLife` profile with a short cache life (the built-in `expire` is `INFINITE_CACHE`) makes every `'use cache'` without an inline `cacheLife()` inherit that short life. In this configuration the nested-`'use cache'` error, in both its short-`expire` and zero-`revalidate` variants, fired in two cases where it should not have. The error exists to catch a nested cache silently shortening an outer cache that has no explicit `cacheLife`, degrading it to a dynamic hole the developer did not choose. But with a short default profile, a single non-nested `'use cache'` already resolves to a short life with nothing nested, so the error fired with no nesting at all: in production this killed the build, and in development it threw on the request. And even for a genuinely nested cache, the warning is pointless here, because the default profile already makes every cache a dynamic hole, so there is no silent degradation to surprise the developer. The throw condition keyed on a short life that was not set through an inline `cacheLife()`, and a value inherited from the `default` profile is non-explicit, so it matched. This change additionally requires that a dynamic nested cache actually propagated its short life upward (`dynamicNestedCacheError` is set) and that the `default` profile is itself prerenderable. Otherwise the short-lived entry is omitted as a dynamic hole instead, exactly as an inline short `cacheLife()` already was. Genuine nesting under a prerenderable default profile still errors. The nesting condition also subsumes the dev-only private-cache exclusion: a private cache's `revalidate: 0` is forced by us rather than by a nested cache and never carries a nested error, so the explicit `kind !== 'private'` check is no longer needed.
-
Hendrik Liebau authored
A `'use cache'` value with an explicit `cacheLife({ expire: 0 })` is expired the moment it is produced, so in production the `'use cache'` wrapper regenerates it on every read rather than serving the stored copy. The entry written to the cache handler is never served back, so persisting it is wasted work, and for a remote handler a needless round-trip and stored payload. Whether to skip that write is left to each cache handler. This change implements it in the built-in default handler; a custom handler can opt into the same behavior. Beyond the saved write, this makes `cacheLife({ expire: 0 })` a reliable way to keep a value out of the server-side cache handler, which covers two cases. In a conditional opt-out, a function with an otherwise normal cache life sets `expire: 0` for a result that is not worth persisting, for example when an upstream fetch errored. In client-only caching, a value is `expire: 0` by design so that it lives only in the client cache, via Cached Navigations or Runtime Prefetches when the route opts in, and never on the server. The skip is gated on `!process.env.__NEXT_DEV_SERVER`. In production the value is regenerated on every read regardless, so not storing it changes nothing that is served. Development keeps storing it, because the default handler's minimum retention serves the previously cached value across reloads while the entry re-warms in the background. A new `use-cache-default-handler-expire-zero` end-to-end test enables the default handler's debug logging (`NEXT_PRIVATE_DEBUG_CACHE`) and asserts on its `set()` decisions. Because the debug output is only available from the CLI, the test skips deployment. -
Benjamin Woodruff authored
https://vercel.slack.com/archives/C04KC8A53T7/p1783018076576349 <img width="1015" height="347" alt="Screenshot 2026-07-02 at 11 57 05 AM" src="https://github.com/user-attachments/assets/74d99079-d165-435a-aece-161862795ef6" /> If we're in the middle of a stack, but the PRs below us in the stack are already merged, we should not skip CI jobs. This logic isn't smart enough to handle that.
-
dan authored
Currently this drops a history push: ```tsx router.push('/target') // this entry was getting lost router.refresh() ``` So you end up on `/target`, but the previous page's history entry was replaced instead of a new one being pushed. As a result, pressing Back yanks you past the previous page. It seems like a regression from #88046. I verified it's broken in 16.2, but it was working in 16.1. This fixes the regression. ## Test Plan New test fails before, works after. Also tried it in a small repro project. --- *Everything below is written by Claude.* The push happens when React commits a state whose `pushRef.pendingPush` is true (`HistoryUpdater`). Refresh-type actions (`refresh`, `hmr-refresh`, `server-patch`) create their state with a fresh `pushRef` where `pendingPush` is false. React can skip committing the superseded navigation state entirely, so `pendingPush: true` is never observed and the push never happens — `HistoryUpdater` replaces the previous page's history entry with the new URL instead of pushing a new one. Going back after that does nothing: the entry the browser returns to has no state, and the popstate handler ignores entries without state. The old router carried the previous state's `pendingPush` forward unless a reducer set it explicitly (https://github.com/vercel/next.js/blob/5ccc9078e0/packages/next/src/client/components/router-reducer/handle-mutable.ts#L41-L43), and the refresh reducer never set it. That guard was lost in #88046, which deleted `handleMutable` and moved the final state assembly into `completeSoftNavigation`, where `pushRef` is created fresh with `pendingPush: navigateType === 'push'`. This PR restores the old behavior there. There's no double push: if the navigation's state did commit, the push already happened and consumed the flag (`HistoryUpdater` mutates the `pushRef`), and its same-URL check turns a leftover flag into a replace anyway. In dev, an `hmr-refresh` dispatched while compiling the destination route on demand can supersede the navigation the same way. That's what's behind the recent `browser back to a revalidated page` flakes in `navigation.test.ts` (traced in #95385). <!-- NEXT_JS_LLM_PR --> -
Vercel Release Bot authored
Co-authored-by:next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
-
Partha Shankar authored
## What? The current `cacheHandlers` validation uses `/[a-z-]/`, which only checks whether a key contains at least one lowercase letter or hyphen. As a result, invalid keys such as `abc123`, `abc_123`, `abc.def`, and `handler!` are accepted even though they contain characters outside the documented allowed set. ## Why? The validation error states that handler names must only contain `a-z` and `-`, but the current implementation does not enforce that constraint because the regex is not anchored. ## How? - Replace `/[a-z-]/` with `/^[a-z-]+$/` so the entire handler name is validated. - Add regression tests covering both valid and invalid handler names. ## Testing - Added regression tests in `packages/next/src/server/config.test.ts`. <!-- NEXT_JS_LLM_PR -->
-
Benjamin Woodruff authored
This is embarrassing, I wasn't paying enough attention when I put up #95374. We have to both change the build dependency *and* switch the machine type...
-
Hendrik Liebau authored
The Instant Navigation feature locks navigation to a route's static shell so you can inspect the prefetched shell before any dynamic content streams in. It is controlled by a cookie: in development the Instant Navigation DevTools set and clear it for you, and in any environment you can drive it by hand by setting the cookie in the browser's DevTools. A blocking route (one with a Suspense boundary above `<body>`, or `export const instant = false`) has an empty static shell, so when you do a full page load of such a route while the cookie is set, that empty shell is served as a blank document with no way to release the lock, and every reload renders the same blank shell and leaves you stuck. Previously the handler threw for an empty shell. In development that surfaces as the error overlay, which is what we want, and the catch clears the cookie so a reload recovers. It did not recover when deployed: the cookie could only be cleared via `Set-Cookie`, which cannot take effect there because the empty shell is served from the ISR cache with its response headers already committed, so the user stayed on the blank shell across reloads. In `next start` it recovered but rendered only a generic "Internal Server Error" page. With this change a deployed blocking route recovers. For the empty-shell case we serve a minimal document whose inline script clears the cookie client-side, so the next full page load renders the route normally; we clear it from the document rather than with `Set-Cookie` because the headers are already committed when the shell is served from the cache. Development still throws so the error overlay shows. As a secondary improvement, `next start` now serves that same document with a readable explanation instead of the generic "Internal Server Error" page. The blocking-route test now asserts the user-facing outcome (after a reload the route renders normally) rather than transport details such as the status code and `Set-Cookie`, which legitimately differ across dev, `next start`, and deploy, and it now runs on deploy as well.
-
Hendrik Liebau authored
This makes full-page loads work under the Instant Navigation Testing API on a deployment, not just under `next dev` and `next start`. With the API active, a full-page load (a reload, an MPA navigation, or direct URL entry) on a deployment failed with a minified React hydration error, and releasing the lock then hard-reloaded the page instead of resolving client-side. Client-side navigations under the lock already worked; the gap was full-page loads. The API works by injecting an inline script that sets `self.__next_instant_test`, which the client reads at `app-index` init as its hydration source. That read only happens on a full-page load; client-side navigations go through the segment cache and the lock and never read it. The script was previously injected at request time through a transform stream, which runs only when the function renders the document. On a deployed full-page load the browser instead parses the prebuilt static prelude served from the edge cache, which was prerendered without the cookie and so carried no script, leaving `self.__next_instant_test` undefined. When the testing API is enabled (in development, or in a production build via `experimental.exposeTestingApiInProductionBuild`), we embed the cookie-guarded bootstrap into the prerendered prelude through React's `bootstrapScriptContent`, so it lands in the cached static shell and runs before the client bootstrap module. That production-build flag is meant for protected preview environments, so a normal production build never embeds the script, and even where it is embedded it stays inert on requests without the instant-navigation cookie (the prelude is shared across all requests). The same content is folded into the dynamic render path in `renderToStream`, and the now-redundant request-time transform is removed.
-
Hendrik Liebau authored
Under the Instant Navigation Testing lock, an MPA page load's bootstrap writes the captured cookie value asynchronously via `cookieStore`. When a scope is released (the external actor deletes the cookie), that pending write can land in the narrow gap between the delete and the deleted-event handler that tears the lock down, resurrecting the cookie after the scope has ended. If the unlock then falls back to a hard reload, which happens when the freshly loaded shell has not hydrated the router yet, the reload carries the resurrected cookie, the server serves the shell again, and the page re-enters instant mode with no scope left to release it, so the deferred content never streams in and the navigation hangs. Once the lock is released, `writeCookieValue`'s guard rejects any further captured write, so the deleted-event handler now clears the cookie right after `releaseLock` to neutralize a write that resurrected it in the gap, and an added guard ignores the re-entrant change event that the clear itself produces. This removes a family of flaky timeouts in `instant-navigation-testing-api.test.ts`, where a full-page (MPA) navigation inside an `instant()` scope would intermittently never stream in its deferred content after the scope exits. [Example failing run](https://github.com/vercel/next.js/actions/runs/28572283366/job/84712848241?pr=95227) --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback
💬 </a></sub> -
Joseph authored
Fixes: https://github.com/vercel/next.js/issues/95395 ```console let x = {} x['constructor']; // function x['toString']; // function x = Object.create(null); x['constructor']; // undefined x['toString'] // undefined ```
-
Andrew Clark authored
### Why Most viewport prefetches are scheduled via a shared `IntersectionObserver`. When several links enter the viewport at once (e.g. on initial load), the observer reports them in document order and we scheduled them in that order. Because the prefetch scheduler gives the highest priority to the *most recently scheduled* task, this meant the link **lowest** in the document ended up with the highest priority — the opposite of a sensible default. ### What Iterate each observer batch in reverse, so the link nearest the **top** of the document is scheduled last and therefore prioritized. The topmost link isn't guaranteed to be the most important, but as a default heuristic it's more reasonable than favoring whichever link happens to be lowest in the document. Also updates the two hover tests in `prefetch-scheduling`, whose expected ordering was coupled to the old bottom-first default (the set of route trees prefetched within the concurrency limit flips from pages 7,6,5,4 to 1,2,3,4). The behaviors they assert are unchanged, and a new test covers the top-of-document prioritization. --- Supersedes #94902, which was opened from a fork. The "Test new and changed tests when deployed" jobs cannot pass on fork PRs — `vercel link` fails with "No existing credentials found" because `secrets.VERCEL_ADAPTER_TEST_TOKEN` is not available to `pull_request` runs from forks. This PR is the same change (rebased onto latest canary) on an upstream branch so the deploy jobs get credentials. <!-- NEXT_JS_LLM_PR -->
-
Andrew Clark authored
With `cacheComponents` + `partialPrefetching`, navigating to an already-prefetched route with a dynamic `generateMetadata` left `document.title` permanently empty until a hard reload. The prefetch cached the head as complete using the server's `isHeadPartial` flag, which is unreliable under Cache Components. Derive the head's partiality from `isResponsePartial` instead, as segment data already does, so a dynamic head is fetched and applied on navigation while a fully static head stays complete. Fixing the flag exposed a latent issue in the prefetch scheduler: during a speculative prefetch, the head was unconditionally runtime-prefetched, which previously went unnoticed because the head was mismarked as complete. The head is now runtime-prefetched only when a segment in the new part of the tree is a candidate for runtime prefetching — it rides along with that request rather than spawning a standalone one. If nothing in the new part of the tree is a runtime prefetch candidate, the head is fetched during the navigation instead. This makes the scheduler's metadata-only request path dead code, so it's removed. Fixes #95268. <!-- NEXT_JS_LLM_PR -->
-
Hendrik Liebau authored
Development has recently gained several mechanisms that make `'use cache'` reloads fast under Cache Components: `'use cache: private'` entries are persisted in a dedicated in-memory handler, `cacheMaxMemorySize: 0` uses a real in-memory handler instead of the no-op stub, and custom handlers are fronted by a fast built-in handler through the tiered handler. One case was still missing. A value that opts into a dynamic, client-only life with an explicit short `expire` (for example `cacheLife({ expire: 0 })`, or the built-in `'seconds'` profile) was treated as a miss on every reload, for both the built-in default handler and custom handlers, so reloads re-ran the cache function and streamed slowly. The reason is that `expire` is the value's expiration bound, the longest it may still be served before it has to be treated as expired. That is its purpose in both dev and production; what differs is which threshold the built-in in-memory handler enforces. In `next dev` it serves stale entries up to `expire` to keep reloads fast, whereas in production it drops them earlier, once past `revalidate`. An `expire` of zero therefore leaves the dev handler no window in which a reload can be served from the cache, and the wrapper's serve-vs-regenerate check, which also keys on `expire`, regenerates instead. This change extends the same dev-only treatment to those values without altering their resolved cache life. The built-in default handler now retains an entry for at least `MIN_PRERENDERABLE_EXPIRE` in dev, a minimum the custom front handler inherits by being a built-in default handler, and the wrapper applies the same minimum when deciding whether to serve or regenerate. That affects the retain and serve decisions only; the entry keeps its real `expire`, so the staged dev render still resolves it at the appropriate stage rather than in the shell stage. A short-`expire` entry is also re-warmed in the background on every dynamic request render, so a reload serves the previously cached value immediately and the freshly recomputed one appears on the next reload. This is the same stale-while-revalidate trade-off already accepted for the private-cache and `cacheMaxMemorySize: 0` dev optimizations, which likewise favor a fast reload over serving a value these configurations would not otherwise cache at all. For custom handlers the re-warm re-executes the function and writes through to the backing. Unlike the private-cache case, we deliberately do not force a dynamic cache life here, because forcing `revalidate: 0` would leak into the cache life propagated to an enclosing `'use cache'` and trip the nested-dynamic error with the wrong message. And unlike the size-0 case, keeping the resolved life alone is not enough, because a short `expire` is exactly what makes the dev handler drop the entry, which is why the minimum retention is needed. Because the dev front handler now enforces that minimum, the tiered handler can no longer evict a stale front entry by writing `expire: 0` (the minimum would keep it alive), so `toExpiredEntry` now writes a negative `expire`, which the default handler recognizes as an eviction sentinel and reports as missing regardless of the retention minimum. This mirrors the existing `revalidate = -1` convention, though a negative `expire` means the entry is dropped rather than served-but-revalidated. Everything is gated on `process.env.__NEXT_DEV_SERVER`, so production behaves exactly as before: short-`expire` values keep their real cache life, and configured handlers are used directly. New development tests cover the built-in and custom-handler cases, asserting that a cache-miss navigation shows the Suspense fallback while a cache-hit one does not, and that a reload serves the cached value yet converges to a fresh one. --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback💬 </a></sub> -
next-js-bot[bot] authored
-
Sebastian "Sebbie" Silbermann authored
-
Hendrik Liebau authored
The Instant Navigation Testing API suite set `skipDeployment: true`, so it only ran under `next dev` and `next start`, which never exercise the real `instant()` flow against a deployment, where the prefetched shell is served from the ISR or edge cache rather than rendered per request. This removes `skipDeployment` so the suite runs on deploy and can catch regressions that are invisible locally. Running the suite on a deployment surfaced that the `runtime params are excluded from instant shell` tests, which asserted that `/dynamic-params/unknown` keeps its param out of the instant shell, do not hold there. That route defines `generateStaticParams` (for `hello`), which makes its fallback shell upgradeable: on a deployment the first concrete navigation to a non-listed param triggers a background prerender of the upgraded shell with that param, whose result (HTML and all segments) is written into the ISR cache. Subsequent prefetches then read those upgraded segments, so the prefetch the instant shell reads already contains the resolved param and the Suspense fallback never appears. The same fallback-shell upgrade is expected under `next start`, which is meant to persist the background prerender to disk, but for reasons to be investigated separately it does not currently affect these prefetches there, so the assertion held under `next dev` and `next start` but broke on a deployment. This upgrade is correct behavior, because a non-listed route param legitimately becomes static once the route has been prerendered for it, so it is not a reliable runtime value to assert exclusion on. The exclusion tests now run against a route that defines no `generateStaticParams` and is never upgradeable (`ungenerated-params/[slug]`), so its param never enters the prefetched shell: under the instant lock the Suspense fallback is shown, and the resolved value appears only after the lock is released. The client-navigation, page-load, and hover-prefetch variants share that route with a stable param and are grouped with the existing ungenerated-params case, whose duplicate client-navigation test is removed. With the exclusion tests moved off it, the `dynamic-params/[slug]` route only serves the statically generated `hello` slug, so it is renamed to `static-params/[slug]` and continues to back the `statically generated params are included in instant shell` tests. The `runtime params are excluded from instant shell` describe now holds only the search-param cases and is renamed to `search params are excluded from instant shell`. A larger set of tests now stays skipped on deploy. Any test that drives a full-page load under the instant lock, whether a plain-anchor MPA navigation or a reload, relies on the lock re-engaging on the freshly loaded document through the prerendered-shell bootstrap (`self.__next_instant_test`), which is only embedded into the deploy-served prelude in #95222. Without it the lock engages unreliably on a deployment, so the out-of-band client fetch is not blocked and the deferred data never streams back, and these tests time out or fail. The `clears the instant cookie and serves an error when the static shell is empty` test stays skipped for a separate reason, a blocking route whose empty static shell would otherwise leave the user stuck, which #95227 fixes.
-
Hendrik Liebau authored
A locked instant() navigation could time out flakily on routes that use runtime prefetching (e.g. `allow-runtime` pages). The navigation reads the segment cache only after its prefetch drains, but the prefetch only awaits the entries it spawned itself. When an earlier prefetch in the scope had already started a more-specific runtime upgrade (a `PPRRuntime` page entry) that was still in flight, the navigation reused that entry without tracking it, drained without waiting for it, and read while it was still pending. The read then fell back to the less-specific fulfilled `RuntimeShell` entry (the static shell with no resolved value), so the awaited content never surfaced and the test timed out. The race only lost under CPU contention, which is why it reproduced in the prod flake-detection job on slow containers but almost never locally. This change tracks an in-flight entry at the point the navigation reuses it. In `readOrCreateSegmentCacheEntry`, when a locked navigation reuses an existing `Pending` entry it did not spawn, it now registers that entry on the navigation's prefetch via `trackNavigationLockPrefetchEntry`, so the prefetch awaits it before the navigation reads. The read then finds the resolved entry rather than the shell. The fix is content-neutral: the entry is looked up by the concrete vary path, so it is whatever the navigation would read at that key regardless. Tracking only controls whether the navigation awaits the entry now versus suspends on it during render, so it cannot surface an entry the navigation would not otherwise read, and it leaves session ownership untouched (so reads still never miss). Tracking is deduped, so reusing an entry the navigation already spawned is a no-op. This also lowers the per-action timeout in the `instant-navigation-testing-api` test suite to below jest's test timeout, so a future stalling `waitFor` fails with its own locator (naming the element that never appeared) instead of a bare test-level timeout that hides which assertion hung. That edit also marks the suite as changed, so CI's flake-detection job re-runs the previously flaky runtime-prefetch tests and confirms they are now stable. --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback
💬 </a></sub> -
Hendrik Liebau authored
The `blocking-fallback/[lang]/[scope]` fixture's deeper page previously rendered a static title and gated its only dynamic work on a `cookies( ` read. Under instant() the committed app shell is allowed to read reque t cookies without blocking, which is exactly what the cookie assertions n this suite rely on, so a segment gated only on cookies renders into th shell and its title commits while the lock is held. Under CPU load thi surfaced as a flaky leak of `blocking-scope-title` during the parke navigation, and instrumenting the lock's read path confirmed the cause the test failed precisely when the app-shell (RuntimeShell) entry committe the deeper segment and passed when the speculative static prefetch (PPR) e try committed, a commit-order race between the two prefetch responses This change makes `ScopePage` await `params` before rendering anything. Because `scope` is an uncovered fallback param (the route has no `generateStaticParams`), awaiting it suspends the whole segment during the app-shell prerender and keeps both the title and the cookie value out of the committed shell regardless of which prefetch wins. The segment streams in only after the lock releases, when the real dynamic render resolves `params`. The underlying app-shell-versus-speculative-prefetch race is a known, likely temporary limitation; the `cookies in the instant shell` describe block documents the related case and the planned fix of opting cookie-reading routes into partial or runtime prefetching. The test comment is updated to describe this param-gated parking instead of the previous cookie-based description. --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback
💬 </a></sub> -
Hendrik Liebau authored
The Instant Navigation Testing helper threw `An instant() scope is already active` whenever it found the `next-instant-navigation-testing` cookie set at acquire time. Because Playwright reuses one browser context across every test in a file, a cookie left behind by an earlier scope poisoned the shared jar and made every following `instant()` call fail fast, cascading through the suite. The cookie can outlive its scope: under the lock, each MPA page load asynchronously re-writes it via `cookieStore`, and that write can land right after the scope's release deletes it but before the client observes the deletion, resurrecting a captured-state entry that the change handler then ignores. Nesting is now tracked in-process, keyed on the browser context, rather than inferred from cookie presence. The context is the right granularity because the instant cookie is context-scoped: concurrent scopes on the same context share one cookie and conflict, while scopes on separate contexts or browsers are independent and must both run. On acquire we clear any stale cookie instead of throwing, and the release re-reads and re-deletes until the cookie stays gone, defeating the resurrection race. New tests cover recovery from a leaked cookie and concurrent scopes across separate contexts. --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback
💬 </a></sub> -
Benjamin Woodruff authored
Running CI only on the top and bottom of the stack avoids expensive `O(n^2)` behavior when merging one PR at a time and recursively rebasing all the others starting at the bottom of the stack. GitHub added this to the webhook/GH actions object for us to be able to do this: https://vercel.slack.com/archives/C01SKER9S1G/p1777926655162839 Prior to this PR being part of a stack, fails open (runs full CI): <img width="1938" height="993" alt="Screenshot 2026-06-26 at 3 03 37 PM" src="https://github.com/user-attachments/assets/54d6055a-2860-45b3-a03a-a9356b3db2a4" /> Example mid-stack run (skips the full e2e jobs): <img width="1917" height="664" alt="Screenshot 2026-06-26 at 3 24 33 PM" src="https://github.com/user-attachments/assets/9ee466da-f3ea-4298-b5b8-2527d197c121" /> https://github.com/vercel/next.js/actions/runs/28268549361/job/83760907003?pr=95219
-
Aurora Scharff authored
## What Removes the `silence this warning` phrasing from the structured fix lines in instant validation output: - `- [block] Set \`export const instant = false\` to ~~silence this warning and~~ allow a blocking route` - `- [ignore] Set \`export const instant = false\` to ~~silence this warning and~~ opt the route out of instant-navigation validation` - `- [ignore] Set \`export const instant = false\` to ~~silence this warning and~~ opt the dropped segment out of instant-navigation validation` ## Why The line called itself a warning while being logged via `Error:`. This PR originally renamed it to `silence this error`, but that has the mirror problem: at validation level `warning` or `manual-warning` (or when the check only surfaces in dev) nothing blocks, so "error" over-claims. The verb is also wrong either way. Setting `instant = false` doesn't silence a problem that still exists. It declares that blocking is acceptable for the route, so validation stops treating it as one. Removing the clause leaves wording that is correct at every validation level and matches the dev overlay cards ("Allow blocking route", "Disable validation on this route") and the docs sections the lines link to. ## How - `blocking-route-messages.ts`, `dynamic-rendering-utils.ts`: drop `silence this warning and` from the `[block]` lines - `instant-messages.ts`: drop it from the `[ignore]` lines (unrendered segment, link prefetch) - `errors.json`: regenerated, append-only (codes 1394-1405) - Storybook fixture and 15 test files updated to the new strings <!-- NEXT_JS_LLM_PR --> -
Dmitrii authored
## What? Fixes Turbopack failing to resolve imports using the common `"#/*": "./src/*"` pattern in `package.json` `imports` field. ## Why? The resolver had an early-rejection check that incorrectly blocked all specifiers starting with `#/`: ```rust if specifier == "#" || specifier.starts_with("#/") || specifier.ends_with(/) { // emit error, return unresolvable } ``` Node.js and webpack (enhanced-resolve) both support the widely-used TypeScript pattern: ```json "imports": { "#/*": "./src/*" } ``` When a user writes `import x from '#/greeting'`, the specifier `#/greeting` starts with `#/`, so Turbopack was erroneously rejecting it before attempting the `imports` field lookup. Only bare `#` and directory-trailing `/` specifiers should be rejected early — `#/something` is perfectly valid and should reach the `imports` field resolver. Since Turbopack is a drop-in webpack replacement in Next.js, it should support the same resolution patterns. The `AliasMap` already handles wildcard pattern matching correctly once the early rejection is bypassed — removing the `starts_with("#/")` guard is sufficient. ## How? - Remove `specifier.starts_with("#/")` from the early rejection condition in `resolve_package_internal_with_imports_field` - Add a test fixture (`subpath-imports-slash`) that validates `#/*` wildcard imports resolve correctly ## Testing New test case in `turbopack/crates/turbopack-tests/tests/execution/turbopack/resolving/subpath-imports-slash`: ```json { "imports": { "#/*": "./src/*" } } ``` ```js import greeting from '#/greeting.js' it('should resolve #/* subpath imports', () => { expect(greeting).toBe('hello') }) ``` Closes #94290
-
- 01 Jul, 2026 15 commits
-
-
next-js-bot[bot] authored
-
Benjamin Woodruff authored
IT increased the concurrency limit from 50 to 100. This ramps back up the `build_and_test` job. I'll keep an eye out for long queue times before migrating us all the way back to arm64. https://vercel.slack.com/archives/C0B0LKK5QD7/p1782910263667649?thread_ts=1782838752.523649&cid=C0B0LKK5QD7
-
Hendrik Liebau authored
The `DYNAMIC_EXPIRE` and `DYNAMIC_STALE` constants read as if the value itself is a dynamic expire or stale time, but every comparison is `expire < DYNAMIC_EXPIRE` / `stale < DYNAMIC_STALE`, so the value is the exclusive upper bound of the dynamic range: it is the smallest value that is *not* dynamic, not a dynamic value. The names are backwards at the boundary, which is easy to misread. The two thresholds also gate different things. `expire` gates whether a cache entry is included in the static prerender: below the threshold it becomes a dynamic hole, though a short-`expire` value is still served during a runtime prefetch. `stale` gates whether an entry is included in a runtime prefetch or app shell. This renames them to name that consequence: `MIN_PRERENDERABLE_EXPIRE` and `MIN_PREFETCHABLE_STALE`. It reads correctly both at the comparison sites (`expire < MIN_PRERENDERABLE_EXPIRE` is "below the minimum prerenderable expire", i.e. dynamic) and at the one site that uses the value directly, where private caches force `expire: MIN_PRERENDERABLE_EXPIRE` precisely because it is the shortest expire that stays prerenderable (and so is retained without being reclassified as a short-expire dynamic hole). This is a pure rename with no behavior change. --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback
💬 </a></sub> -
Vercel Release Bot authored
Co-authored-by:next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
-
Hendrik Liebau authored
Deploy tests recover the `BUILD_ID`, `DEPLOYMENT_ID` and `NEXT_SUPPORTS_IMMUTABLE_ASSETS` values by scraping them out of the deployment's build logs, where the test fixture's `post-build` script prints them as the final lines of the build. We fetch those logs with `vercel inspect --logs` after `vercel deploy` returns, but a deployment can report `Ready` before its full build-log tail has propagated to the log query API, so a single call sometimes returns a truncated prefix that stops before the markers. When that happens `parseIdsFromCliOuput` throws "Failed to get buildId from logs" and fails the whole suite during setup, which is the intermittent failure we have been seeing across the deploy jobs. This change wraps the log fetch in `fetchBuildLogsUntilComplete`, which re-queries `vercel inspect --logs` until the last-printed marker (`NEXT_SUPPORTS_IMMUTABLE_ASSETS`) appears before parsing, bounded to twenty attempts three seconds apart. Gating on the final marker rather than the first ensures a partial read cannot slip past the loop into the parser. Streaming the logs from `vercel deploy --logs` as part of the deploy itself was considered, but it has the same race: the CLI stops streaming once the deployment reports `Ready`, before the `post-build` tail flushes, and a single stream cannot re-query for the missing lines.
-
next-js-bot[bot] authored
-
Jiwon Choi authored
> [!TIP] > Best reviewed with hide whitespace. ### Why? Cache Components prerenders can fail when an OpenTelemetry tracer is acquired before provider registration and later resolves through proxy tracer delegation: ``` Next.js encountered the unstable value `Math.random()` while prerendering ``` Current behavior: https://github.com/vercel/next.js/actions/runs/28518518762/job/84536475151?pr=95317#step:32:343 ### How? Patch proxy tracer delegation to apply the same Cache Components span instrumentation used for normal tracer lookup. Closes https://github.com/vercel/next.js/issues/94753 <!-- NEXT_JS_LLM_PR -->
-
Luke Sandberg authored
### What? When profiling is enabled (`--experimental-cpu-prof` / `--internal-trace`, or the `NEXT_CPU_PROF` / `NEXT_TURBOPACK_TRACING` env vars), Next.js writes a `.gitignore` containing `*` into `.next-profiles/` as it creates the directory. This keeps the profiling output out of git and out of the way of tools that scan the project tree. ### Why? `.next-profiles` is a sibling of `.next`, so it's intentionally *not* covered by the `.gitignore` create-next-app ships. The motivation was that profiles wouldn't bloat `.next` and wouldn't be silently ignored. But a sibling dir full of large profile/trace files turns out to be a liability: - **Ecosystem tools scan it.** Tailwind v4 aggressively auto-scans files and has opened a `trace-turbopack.bin` and crashed; Turborepo <2.8.13 hashes the file and OOMs, and >=2.8.13 fails to start `dev` watchers because reading the large trace is too slow. (workflow watchers are likely affected too.) - **Turbopack NFT globbing** can read/hash the file via overly broad `fs.read` patterns. - **Accidental commits.** Pushing a multi-GB trace would be miserable for a customer helping us debug. These have each gotten point bandaids (#94587, #94570), but the real fix preserves the original motivation: a nested `.gitignore` with `*` keeps the files off git **and** makes gitignore-respecting tools (Tailwind, Turborepo) skip the whole subtree, which resolves the scanning failures. Reverting to `.next/profiles` was the alternative; the gitignore approach keeps the existing path. ### How? - `ensureProfilesDir()` (`packages/next/src/lib/profiles-dir.ts`) creates `.next-profiles` and writes the `.gitignore` (only if absent, so user edits survive). Single source of truth. - `bin/next.ts` calls a `setupProfilesDir()` helper on build/dev/start, gated on the env vars so both the CLI flags and direct env-var usage are covered. Skipped when `NEXT_TURBOPACK_TRACING_PATH` redirects trace output. - Rust keeps `create_dir_all` as a backstop for the trace dir; the `.gitignore` is written in JS only. - Docs switched from `NEXT_TURBOPACK_TRACING=1` to `next dev --internal-trace`, and the stale `trace-turbopack` filename corrected to `trace-turbopack.bin`. <!-- NEXT_JS_LLM_PR -->
-
Sam Selikoff authored
Fixes the Navigation Inspector in Safari/WebKit on localhost. Safari 18.6 exposes the Cookie Store API, but WebKit on localhost can resolve `cookieStore.set()` and emit a change event without committing a cookie that is visible to `document.cookie` or sent with requests. Since the instant navigation lock depends on a real request cookie, the inspector was not working correctly. This switches instant-nav cookie writes/deletes to `document.cookie`, keeps Cookie Store for observing changes, and makes Resume wait for the delete event before starting the next pending capture.
-
Aurora Scharff authored
## Why Standardize the Insight fix UI across the dev overlay and docs, and round out the docs side with a proper family index at the bottom of every page. ## What - Dev overlay: **Copy as prompt** -> **Copy prompt**; bumped the pill padding to match the new docs button. - Error pages (`errors/*.mdx`, 15 files): `<FixOption>` -> `<FixCardGrid>`/`<FixCard>` with snippets copied verbatim from `instant-guidance-data.ts`; all `https://preview.nextjs.org/docs/...` URLs converted to relative `/docs/...`. - Every Insight error page now ends with a `## Related Insights` index listing the other 14 Insight pages (self omitted). - `instant-navigation.mdx` and `migrating-to-cache-components.mdx`: dropped the stray trailing `}` snippet line so guide cards match dev-overlay heights; added a one-line Copy prompt note linking to `#ai-workflow`. - `insight-error-page` skill: replaced the "Useful links" guidance with "Related Insights" (full family index, no API refs/guides) and matching audit-checklist line. - Minor cleanup in `instant-guidance-data.ts` (trimmed verbose JSDoc to non-obvious bits). ## How Paired with vercel/front#75443 which adds the Copy prompt button to `<FixCard>` and deletes the legacy `<FixOption>`. `pnpm --filter=next types` clean, 23 `instant-guidance-data` tests pass. <!-- NEXT_JS_LLM_PR -->
-
Aurora Scharff authored
## Why Today, running \`npx @next/codemod upgrade canary\` against any default-CNA-15 project fails at \`npm install\` with an \`ERESOLVE\` peer-dep error: \`\`\` Found: eslint@8.57.1 Could not resolve dependency: peer eslint@">=9.0.0" from eslint-config-next@16.3.0-canary.71 \`\`\` The codemod bumps \`eslint-config-next\` (Next 15 -> Next 16) but leaves \`eslint@^8\` alone, so npm can't reconcile peers and the install dies before any jscodeshift transforms can run. Caught while testing vercel/next.js#95312 against \`cna-15.0.0-app\`. ## What Adds \`eslint\` to the \`versionMapping\` in \`upgrade.ts\` when the project has \`eslint\` installed. The new version is picked by reading \`eslint-config-next@<target>\`'s \`peerDependencies.eslint\` range and resolving the highest matching published version (same pattern \`@types/react\` already uses). If anything goes wrong fetching the peer range (network blip, missing peer entry), the bump is skipped and a verbose-only warning is printed — the user just hits whatever they would have hit without this change. ## How \`pnpm --filter @next/codemod build\` clean. To test locally: downgrade a Next 16 project to Next 15 + eslint 8 + react 18, then run \`node packages/next-codemod/bin/next-codemod.js upgrade canary --yes\` and confirm the install succeeds. <!-- NEXT_JS_LLM_PR -->
-
Joseph authored
- Lead use cache Revalidation with explicit cacheLife; split into Time-based and On-demand. - Recommend cacheLife in every use cache scope; drop "optional." - Reorder cacheLife reference: Overriding before Custom; reword both. - Document that overrides reach the generated cacheLife type signature. - Add the override option to the config reference and migration guide.
-
Niklas Mischkulnig authored
Cleanup and improve tests
-
Joseph authored
- Fix/adjust a few code highlights - Section about `use client` as a fix for soft-nav instant insights
-
Joseph authored
- x-ref to `bfcacheId` - add a section on `:has` --------- Co-authored-by:vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
-