- 12 Aug, 2026 26 commits
-
-
next-js-bot[bot] authored
-
Syed Sohail Hussain authored
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors We encourage you to use AI to assist you in researching, creating, and reviewing changes. However, you must review and deeply understand the contributions you are making. For this reason, **pull request descriptions from external contributors must be written by a human**. ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Signed commits - This repository requires verified commit signatures on protected branches. - If this pull request is blocked for unsigned commits, re-sign the commits and force-push the branch. - A `Signed-off-by` line in the commit message is not enough. ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->
-
Luke Sandberg authored
Fixes https://vercel.slack.com/archives/C08V7PA05D4/p1786563625559519?thread_ts=1786557472.558379&cid=C08V7PA05D4 Basically when trying to figure out how old a version is we parse the CURRENT file, for an old version this fails. This PR adds a fallback for mtime and a test This fixes a bug introduced in #96941 which added the new TTL policy
-
Marcos Hernanz authored
## Summary - Let issue authors and people who commented before closure reopen an issue within 14 days using `Reopen: <reason>`. - Limit the automation to unlocked issues closed by triage-or-higher human maintainers, with ordered timeline checks, bot filtering, idempotency, and state revalidation. - Align resolved-issue and contributor guidance with the new reopening window. ## Verification - `Prettier 3.6.2 --check .github/workflows/issue_reopen.yml .github/comments/resolved.md contributing/repository/triaging.md` - Mocked workflow harness covering 19 closure, eligibility, boundary, bot, idempotency, and race scenarios - `autoreview --mode local --stream-engine-output` (Codex and Claude clean) - Live GitHub API spot-check for ordered same-second `commented` and `closed` timeline events - Not run: live issue close/reopen smoke test (issue-triggered workflows run only from the default branch)
-
Sam Poder authored
Adds docs for `clusters`.
-
Luke Sandberg authored
I just reviewed 10+ prs from @marcoshernanz landing trivial edit fixes (on behalf of contributors) and outside of Documentation we really shouldn't encourage this Also, im guessing a link to the issue tracker is more useful than a 40 minute YouTube video
-
Luke Sandberg authored
Mark VersionedContentMap as `serialization = "none"` This will cause every dev session to start with an empty map, to ensure _derived_ data from the old map doesn't survive, the functions interacting with the state are all marked `session_dependent`. This is directly motivated by the work on GC which runs into problems with the State objects storing operations but not consistently `connect`ing to them on cache hits, which causes the GC to drop them. Additionally, this prevents eagerly recomputing all server hmr routes on startup. In theory this will slow down reconnecting a dev session, but the underlying operations are still cached and the tasks computing Versions, so it just the map that needs to be reconstructed, so the cost should be minor. In fact i would guess that it is a bit faster to reconstruct this map than to restore all the keys from disk in the case where the map is large. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors We encourage you to use AI to assist you in researching, creating, and reviewing changes. However, you must review and deeply understand the contributions you are making. For this reason, **pull request descriptions from external contributors must be written by a human**. ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Signed commits - This repository requires verified commit signatures on protected branches. - If this pull request is blocked for unsigned commits, re-sign the commits and force-push the branch. - A `Signed-off-by` line in the commit message is not enough. ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> --- <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> -
Sam Poder authored
The goal of this PR increase the expected benefit of merging two chunks when their overlapping chunk groups are in a "cluster" (a cluster is a set of routes that are commonly visited together). This is because in these cases the Z+Z case (one of six in the N=2 set of cases) is more likely than others. To this I have increased the probability of the Z+Z case. At the moment, to do this I've done the following to the probabilities: ```rust /* MERGED CASE (N = 2): case X + X (p = (a_rem/groups) * ((a_rem - 1)/rem_g)): size = a_size, requests = 1 case Y + Y (p = (b_rem/groups) * ((b_rem - 1)/rem_g)): size = b_size, requests = 1 case Z + Z (p = (o_groups/groups) * (o_groups - 1)/rem_g): size = (a_size + b_size), requests = 1 case X + Y (p = (a_rem/groups) * (b_rem/rem_g) + (b_rem/groups) * (a_rem/rem_g)): size = a_size + b_size, requests = 2 case X + Z (p = (a_rem/groups) * (o_groups/rem_g) + (o_groups/groups) * (a_rem/rem_g)): size = a_size + (a_size + b_size), requests = 2 case Y + Z (p = (b_rem/groups) * (o_groups/rem_g) + (o_groups/groups) * (b_rem/rem_g)): size = b_size + (a_size + b_size), requests = 2 Request count is different in this case: Z + Z (better) Requests size is different (worse) in these cases: X + Z, Y + Z Each cost / benefit is weighted by the probabilities above. There are cases when we know that Z + Z is more likely due to common user behaviour. This is based on the "cluster" chunking heuristic we provide. We increase P(Z + Z) when two or more routes in a cluster request both chunk items together (ie. request Z). P(X + Z) and P(Y + Z) are therefore less likely. To increase P(Z + Z) while maintaining a total probability of 1, we do the following (when chunk items overlap in a cluster): P'(X + Z) = (1/2) * P(X + Z) P'(Y + Z) = (1/2) * P(Y + Z) P'(Z + Z) = P(Z + Z) + (1/2) * P(X + Z) + (1/2) * P(Y + Z) Otherwise: P'(X + Z) = P(X + Z) P'(Y + Z) = P(Y + Z) P'(Z + Z) = P(Z + Z) */ ``` This increases `P'(Z + Z)` while reducing `P'(X + Z)` and `P'(Y + Z)`. It is a bit of a blunt tool for doing this, however. So if anyone has other suggestions for how to change this probabilities while maintaining existing behaviour - let me know!
-
Hendrik Liebau authored
-
Hendrik Liebau authored
The streaming assertion in `should stream suspense boundaries while filling caches in the background` polled a bare `<p>` through `retry()` with its 3000ms default. Because `retry` gives up as soon as `waited + interval > duration`, the effective budget is about 2.6s, and the fixture's cache fill alone takes 2000ms, so the assertion had roughly 600ms of headroom. That budget also had to absorb one browser round trip per attempt, because a selector that matches the fallback as well as the content cannot wait for anything: `waitForSelector` returns the fallback immediately, so the waiting had to happen in the test process at a 500ms granularity. This change gives the two paragraphs the ids `#cached-fallback` and `#cached`, in line with every other route in this fixture, which is what lets the wait move into the browser. Playwright now resolves the moment the content is revealed, in a single round trip, and #95466 had already moved the rest of the suite to that pattern. The two assertions that check what the shell itself delivers still need the original "whichever element arrives first" probe, and they now express it as the selector list `#cached, #cached-fallback` instead of relying on `p` to match both. The budget for the reveal is 10s rather than the 5s that `elementByCss` narrows the harness default to, because the wait has to cover more than the fill. In the linked failure the content bytes had arrived one second after the shell committed, and the reveal was still at least 2.4s away, since the browser was busy evaluating the dev bundle. A shorter fill would not help with that, as it does not shorten the part of the wait that CI actually spends. The convergence assertion in `serves a short-expire cache warm on reload and converges to a fresh value` ran out of the same budget for a different reason: every attempt performed a full dev page reload on top of the 1.5s regeneration, and measured runs needed 1.8s to 3.4s. It now reads the value over HTTP with `next.render$`, the way #97187 does, which observes the same server-side cache state without downloading and evaluating the dev bundle. Under the same contention those reads converge in 1.1s to 1.9s, and they stay there when the load is quadrupled, because only the 1.5s regeneration gates the loop. The default budget therefore covers it, and the test drops from 15.5s to 3.6s. Both fixes were verified by raising the fill to 3.2s to emulate the CI-side delay: the previous assertions then fail deterministically with the CI signature, and the new ones pass. [Flakiness metrics](https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.name%3A%22cache-components-dev-streaming%20should%20stream%20suspense%20boundaries%20while%20filling%20caches%20in%20the%20background%22%20%40test.type%3A%22nextjs%22%20%40test.status%3A%22fail%22&agg_m=count&agg_m_source=base&agg_t=count&citest_explorer_sort=timestamp%2Casc&cols=%40test.status%2Ctimestamp%2C%40test.suite%2C%40test.name%2C%40duration%2C%40test.service%2C%40git.branch¤tTab=overview&eventStack=&fromUser=true&index=citest&start=1783948256248&end=1786540256248&paused=false)
-
Hendrik Liebau authored
The first assertion in `use-cache-default-profile-expire-zero` retried a full browser reload until the `expire: 0` cache produced a fresh value. In dev that value is served warm across reads, so more than one read is needed, and on a CI runner one of those reloads costs more than the default 3000ms budget can grant a second attempt for. The dev failure reports `waited 3162ms` after a single attempt, in a test that took 15.6s to get there. Neither test asserts anything about the browser: both only read the rendered value and check that the nested-cache error stayed out of the CLI output. Reading the value with `next.render$` brings one attempt down to between 30 and 174ms, so the default budget holds, and it drops two browser launches. The helper rejects a missing element, because the empty string that cheerio yields for one would otherwise satisfy the assertion that the value changed. The test predates #96354, which replaced the try counting in `retry` with a clock. Before that change `retry` granted seven attempts regardless of how long each one took, so a 3s reload was affordable; after it, any attempt over 2500ms consumes the entire budget on its own. #97187 makes the same change for two assertions that were failing this way. [Flakiness metrics][flakiness-metrics] [flakiness-metrics]: https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.name%3A%22use-cache-default-profile-expire-zero%20treats%20a%20short%20default%20cacheLife%20profile%20as%20a%20dynamic%20hole%2C%20not%20a%20nested-cache%20error%22%20%40test.type%3A%22nextjs%22%20%40test.status%3A%22fail%22&agg_m=count&agg_m_source=base&agg_t=count&fromUser=false&index=citest&start=1785948830138&end=1786553630138&paused=false
-
Sam Poder authored
Tbh, I don't really understand this code path but this appears to fix the bug. This includes `referenced_output_assets` in `async_chunks`. The bug report went away when `experimental.turbopackServerFastRefresh` was disabled. The agent's explanation (more for entertainment): <img width="967" height="290" alt="Screenshot 2026-08-11 at 5 07 46 pm" src="https://github.com/user-attachments/assets/e57425be-e4e9-44b8-a6eb-8e93d04b37f0" /> Closes https://github.com/vercel/next.js/issues/97206
-
Sebastian "Sebbie" Silbermann authored
Replaces the shared, static `PREVIEW_BUILDS_READ_TOKEN` secret with OIDC tokens for reading auth-protected preview builds from vercel-packages (see https://github.com/vercel/vercel-packages/pull/96): - CI jobs mint a GH oidc token for the `https://vercel-packages.vercel.app` audience - deploys have a `.npmrc` written that uses the Vercel OIDC token Tarball polling now also fails fast on 401/403 (retrying can't change the authorization outcome) and failure messages include response headers so request IDs are available for debugging. Co-authored-by:
Claude Fable 5 <noreply@anthropic.com>
-
Sebastian "Sebbie" Silbermann authored
Fixes ``` [17:03:12] ncc_mswjs_interceptors failed because [tsl] ERROR in /home/runner/work/next.js/next.js/packages/next/src/server/og/cache-image-response.ts(27,17) TS2307: Cannot find module 'next/dist/compiled/@vercel/og/index.node.js' or its corresponding type declarations. ``` -- https://github.com/vercel/next.js/actions/runs/31515393262/job/93859146712#step:8:723 Now we use externalize the `Promise.withResolvers` polyfill to allow running `ncc` before we built `dist`. -
Josh Story authored
## Summary The onBeforeDeferredEntries callback can update deferred source files after Webpack has already cached their contents while building initial entries. This tracks the source directories represented by the deferred entrypoint set and purges only those paths before adding deferred entries so callback-time source is compiled without dropping unrelated filesystem cache state. The deferred entries fixture now primes both deferred sources through Webpack before the callback and also primes a non-deferred source. It verifies deferred entries use updated content while the unrelated source remains cached. ## Verification - `HEADLESS=true pnpm test-start-webpack test/e2e/deferred-entries/deferred-entries.test.ts` - Control run with the old global purge: the build fails because the unrelated cached source is evicted <!-- NEXT_JS_LLM -->
-
next-js-bot[bot] authored
-
Hendrik Liebau authored
#94703 and #95116 both changed how internal headers are kept out of userland `headers()`, and between them they left `headers()` detached from the request it describes. #94703 started stripping the dev-only request-id headers alongside the flight headers that had been stripped for much longer. Those deletes ran against the shared request headers, because `HeadersAdapter.from` returns a `Headers` instance unchanged instead of copying it, and removing the request-id headers there broke the dev debug channel when the dev server rendered a redirect target after a server action. #95116 fixed that by copying the headers before stripping them. Neither change set out to alter whether `headers()` follows the request. The sealed view has read through to the underlying headers for as long as `HeadersAdapter.seal` has existed, and its own unit tests assert that. The copy was only a way to keep the deletes from escaping into `req.headers`, and the detached view was collateral that no test covered. The result, since 16.3.0, is that a Proxy which writes a header onto `request.headers` and then reads it back through `headers()` gets the value from before the write. Reading the same header directly off `request.headers` returns the new value, so two APIs describing the same request disagree, and a second `headers()` call returns the same stale view. Whether the write is seen at all depends on ordering, because the view is built on first access: a write made before the first `headers()` call is observed, and the identical write made after it is not. This change drops the copy and stops deleting anything. `HeadersAdapter.seal` now accepts a set of header names to omit from every read operation, and `getHeaders` seals the shared request headers directly with the flight headers and the dev request-id headers hidden. Both earlier intentions survive. The internal headers stay on the request where the framework still reads them, they stay invisible to userland `headers()`, and the sealed view tracks the request again, so the two APIs agree throughout a Proxy run. Hiding on read is slightly stricter than the delete it replaces. The delete ran once, when the view was created, so an internal header written to the request afterwards would have shown through. It now stays hidden no matter when it is written. While restructuring `seal` we also corrected the `parent` argument that `forEach` passes to its callback. The native method passes the unsealed target, which hands the callback a mutable handle on the underlying headers and defeats the seal. Both the plain and the hiding handler now pass the sealed proxy instead. `cookies()` is unaffected and stays a snapshot, because `RequestCookies` parses the `cookie` header when it is constructed. That predates 16.3 and is left alone here. The fix is based on #97145 by @tachsin. That pull request comes from a fork, and deploy tests do not run for fork pull requests, so it is recreated here on a branch of this repository to get full CI coverage. The commit carries a `Co-authored-by` trailer for them, so their credit is preserved on merge. We also took the liberty of a few improvements over the original: `seal` is restructured into two handlers rather than a guard repeated in each case, `getSetCookie` and `forEach` are handled as described above, and the unit and end-to-end coverage is wider. fixes #97049 closes #97145 --------- Co-authored-by:joaquin <tachsinachmet@gmail.com>
-
Hendrik Liebau authored
The `middleware redirect` test in the app dir navigation suite has been flaky for months. After hydration the fixture posts to `/api/set-token`, calls `router.refresh()`, receives a middleware redirect, and only then does the browser location change. In dev each of those routes is compiled on the first request that reaches it, so the assertion window paid for compilation: on a CI runner the `POST /api/set-token` took about 1.4s and the middleware redirect about 1.1s, while the second occurrence of each of those same requests took 10 to 30ms. With the default 3000ms budget and an attempt as cheap as `browser.url()`, `retry` stops after about 2.5s, which is the `waited 2505ms` that every failure reports, and a chain needing 2.6s of server time never fits. The redirect itself always works. In the failing runs the `307` and the dashboard `200` are both in the server log; they simply arrive after `retry` has given up, so the assertion is the only thing that misses them. Hitting the two routes before opening the browser moves that compilation out of the assertion window. The chain after hydration then costs about 50ms instead of 2.6s, so the existing budget is no longer the thing under test and a real slowdown in the redirect would still fail. The warm-up is skipped outside dev, where nothing is compiled on demand, so production and deploy runs are unaffected. The flakiness predates #96354, which replaced the try counting in `retry` with a clock, but that change made it worse: the old implementation ran a seventh attempt at around 3.0s, which is exactly the window this location change lands in when the runner is slow. [Flakiness metrics][flakiness-metrics] [flakiness-metrics]: https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.name%3A%22app%20dir%20-%20navigation%20middleware%20redirect%20should%20change%20browser%20location%20when%20router.refresh%28%29%20gets%20a%20redirect%20response%22%20%40test.type%3A%22nextjs%22%20%40test.status%3A%22fail%22%20%40git.branch%3Acanary&agg_m=count&agg_m_source=base&agg_t=count&fromUser=false&index=citest&start=1785174487274&end=1786470487274&paused=false
-
Tim Neutkens authored
## Summary Update the gh-stack skill to match the current CLI behavior and make the guidance easier to navigate. Move detailed stack design, command behavior, and troubleshooting material into focused references while keeping the main skill concise, and refresh the lock hash for the finalized content. ## Verification - `pnpm prettier --with-node-modules --ignore-path .prettierignore --check .agents/skills/gh-stack/SKILL.md .agents/skills/gh-stack/references/commands.md .agents/skills/gh-stack/references/stack-design.md .agents/skills/gh-stack/references/troubleshooting.md skills-lock.json` - Verified the three referenced files exist and the computed skill-folder SHA-256 matches `skills-lock.json` - Not run: Next.js tests (documentation-only skill update) <!-- NEXT_JS_LLM -->
-
Hendrik Liebau authored
-
Hendrik Liebau authored
-
Benjamin Staneck authored
## Summary - Preserve Pages Router support entries during Turbopack `--debug-build-paths` selective builds - Include custom Pages Router `404` and `500` entries alongside `_app`, `_document`, and `_error` when a Pages route is selected - Add regression coverage for selected Pages routes retaining support entries in `pages-manifest.json` ## Testing - `RUSTC="$(rustup which --toolchain nightly-2026-06-24 rustc)" cargo check -p next-api` - `RUSTC="$(rustup which --toolchain nightly-2026-06-24 rustc)" pnpm --dir packages/next-swc build-native` - `HEADLESS=true pnpm test-start-turbo test/production/debug-build-path/debug-build-paths.test.ts -t "single page with pages/ prefix"` - `HEADLESS=true pnpm test-start-turbo test/production/debug-build-path/debug-build-paths.test.ts` Fixes #93515 <!-- NEXT_JS_LLM_PR -->
-
Tim Neutkens authored
## Summary Prevent Turbopack from adding `crossorigin=""` to generated script tags when `crossOrigin` is not configured, and add production coverage for static prerendering, dynamic rendering, and `output: 'export'`. This regressed in #92070 when Turbopack added `crossOriginLoading` support. The client reference manifest changed from an optional cross-origin value to the shared `CrossOrigin` enum. Serde serialized the enum's default `None` variant as the string `"none"`, so React saw a present string and treated it as anonymous CORS, emitting `crossorigin=""`. Webpack continued to omit its `undefined` value. Skip serializing `CrossOrigin::None` in the Turbopack client reference manifest so an unset option remains absent while preserving explicit anonymous and credentialed modes. ## Verification - `NEXT_TEST_PREFER_OFFLINE=1 pnpm test-start-turbo test/e2e/app-dir/app-config-crossorigin/index.test.ts` - `NEXT_TEST_PREFER_OFFLINE=1 pnpm test-start-webpack test/e2e/app-dir/app-config-crossorigin/index.test.ts` <!-- NEXT_JS_LLM -->
-
Hendrik Liebau authored
-
Josh Story authored
## Summary - Allow the shared browser runtime to initialize before any async chunk has created the chunk-loading queue. - Preserve duplicate-runtime protection when a runtime registry is already installed. - Update the affected development, production, debug-ID, and worker runtime snapshots. Shared runtime scripts can execute before other async chunks. Previously, the runtime returned when the chunk-loading global was undefined, leaving later registrations queued and preventing the Next.js client bootstrap and hydration from running. ## Verification - `cargo test -p turbopack-ecmascript-runtime` - Targeted Turbopack browser-runtime snapshot fixtures - Generated development and production runtimes evaluated with no pre-existing queue, including duplicate-runtime protection <!-- NEXT_JS_LLM -->
-
dan authored
Claude noticed this while working on https://github.com/vercel/next.js/pull/95391. Basically, the queue's React state always gets updated in the order of dispatching. So if a navigation displaced pending actions, it's the *navigation's* promise that was last. So when the pending action runs after it, that action's state is no longer taken into account, even if it revalidated. This is why the new data won't reflect on the screen. With the fix, the final state is properly reflected. ## Test Plan New test, which was red before the fix. Also tried it on a mini-app. Before: https://github.com/user-attachments/assets/2235b116-82c4-4ef4-a63c-78e157c90470 After: https://github.com/user-attachments/assets/d7b685c7-d0a5-4b91-8da7-78bb14011313 ## How We re-render at the end with the final queue state — if we know it was preempted.
-
- 11 Aug, 2026 14 commits
-
-
Sam Poder authored
This should not be on in 16.3.1.
-
next-js-bot[bot] authored
-
Josh Story authored
## Summary The app loader tree currently mutates Turbopack's parallel route map to ensure `children` is inserted first. This makes the loader tree representation depend on a compatibility ordering that only matters when the tree is emitted as JavaScript. This keeps the generated loader tree unchanged while moving `children`-first ordering to the Turbopack code generator. The output continues to preserve the rendering order added for head and CSS handling during client navigation, while consumers of the internal tree select `children` by key. ## Verification - `pnpm build-all` <!-- NEXT_JS_LLM -->
-
Luke Sandberg authored
In CI we do not retain old versions of the db at all, but in dev or non-CI settings we would retain up to 2 indefinitely. Given how large caches can grow, this PR reduces it to no more than 1 old version, and then only for a certain amount of time, currently 3 days. The idea being to support switching back and forth between feature branches and a next.js upgrade branch, 3 days allows this worflow to survive a weekend. To support this the `CURRENT` file format is modified. Instead of just storing a sequence number it now stores a small json object containing the `max_sequence_number` and the mtime. We store the last_write_time in the file to support the fact that we anticipate `cache` directories to be copied around and the native mtime would record the copy time instead of the commit time. This should reduce dev time disk usage in the common case.
-
Niklas Mischkulnig authored
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors We encourage you to use AI to assist you in researching, creating, and reviewing changes. However, you must review and deeply understand the contributions you are making. For this reason, **pull request descriptions from external contributors must be written by a human**. ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Signed commits - This repository requires verified commit signatures on protected branches. - If this pull request is blocked for unsigned commits, re-sign the commits and force-push the branch. - A `Signed-off-by` line in the commit message is not enough. ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->
-
next-js-bot[bot] authored
-
Sam Poder authored
-
Joseph authored
- Enrich the directives entry point - New guide for Server and Client components. Conceptual backing for the getting started page. --------- Co-authored-by:Aurora Scharff <aurora.sofie@gmail.com>
-
Aurora Scharff authored
## Summary - add an explicit `staleTime` to the server-seeded TanStack Query example so hydration does not immediately refetch - explain when stale TanStack Query data becomes eligible to refetch - clarify that SWR fallback data revalidates after hydration by default and that `revalidateIfStale: false` is not a timed freshness window ## Verification - `prettier --write docs/01-app/02-guides/client-side-data-fetching/{swr,tanstack-query}.mdx` - `alex docs/01-app/02-guides/client-side-data-fetching/{swr,tanstack-query}.mdx --quiet` - Not run: full `pnpm lint` (docs-only change; targeted formatting and language checks passed) <!-- NEXT_JS_LLM --> -
Andrew Clark authored
Fixes a few bugs related to optimistic routing. Originally reported as a next-intl request waterfall in MarkBekooy/prefetching-request-waterfall-bug#1, then extracted into an isolated regression test: A proxy that rewrites every URL to inject a leading path segment (`/one/two` → `/en/one/two`, i.e. i18n with the default locale hidden from the URL) plus a fully dynamic target route like `/[locale]/[...pages]` leads to an infinite prefetch loop that never resolves. This regression uncovered several oversights in the optimistic routing implementation: when receiving a prefetch response, we did not check whether the response matched the expected result. If the tree mismatched, in some cases the prefetch task would fall into a loop, repeatedly attempting to fulfill the missing data. Now when this happens, we record on the local route definition that a dynamic rewrite occurred, disabling further attempts to optimistically resolve the route. This is the same strategy we were already using for normal navigation responses, now applied to the prefetch path. We also received another bug report with a similar root cause: parallel routes with conflicting dynamic params at the same level (`@modal/[...catchAll]` next to `[username]`) cannot be distinguished using the current traversal algorithm, because it assumes that each segment is resolvable independently without inspecting the children or sibling branches. To work around this issue for now, when this scenario is detected, we disable optimistic routing for the conflicting route. We can model this properly in a future PR by having the server send down the "sibling" dynamic route segments, similar to what we do for static siblings already. Fixes #97135 <!-- NEXT_JS_LLM -->
-
Aurora Scharff authored
## What changed - Expands the SPA data-fetching guidance with focused SWR and TanStack Query guides. - Covers client-only fetching, optional Server Component seeding, shared cache identities, and optimistic mutations. - Explains how the Next.js server and client caches relate to library-owned browser caches, including SWR `preload` and TanStack Query hydration with Cache Components. - Aligns the examples with `next-spa-patterns` and the team chat demo. ## Validation - Prettier and diff checks pass for the updated guides. - `next-spa-patterns` passes TypeScript checks.
-
kelvin authored
### What? Adds support for passing a module type to the TypeScript overloads for `import.meta.glob`: ```ts const entries = import.meta.glob<Entry>("./entries/*.ts"); ``` This works with both lazy and eager imports. If a module type isn’t provided, it defaults to `unknown`, which matches the current behavior. ### Why? Next.js already supports Vite’s `import.meta.glob` API at runtime, but its TypeScript declarations don’t support [Vite’s module generic](https://github.com/vitejs/vite/blob/57fea001d154e7dd8d5d74d3082731f1dcfd31be/packages/vite/types/importGlob.d.ts#L113-L130). Because of this, a typed glob works in Vite but fails in Next.js: ```text TS2558: Expected 0 type arguments, but got 1. ``` Consumers currently have to cast the result or add their own `ImportMeta` declaration to describe the matched modules. Supporting the generic removes the need for those workarounds and makes typed glob imports consistent between Next.js and Vite. ### How? Each existing overload now accepts a generic module type, `M`, which defaults to `unknown`: - Lazy imports return `Record<string, () => Promise<M>>`. - Eager imports return `Record<string, M>`. Using `unknown` as the default means existing calls without a generic keep the same types as before. I also updated the existing e2e fixture. It had an old local `ImportMeta.glob` declaration that returned `Record<string, any>`. Removing that declaration exposed the missing generic and allowed the five `as any` casts in the fixture to be removed. Without the generic, all five glob calls fail during `next build` with `TS2558`. With it, all five pass. The Turbopack documentation has also been updated with examples showing how to use the generic with lazy and eager imports. ### Checklist - [x] `pnpm --filter=next types` passes - [x] `pnpm prettier-fix` run - [x] Documentation follows the docs contribution guide - [x] E2E test passes --------- Co-authored-by:Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
-
Aurora Scharff authored
## Summary Rename the guide to `How to implement authentication with Cache Components` so it follows the wording of the main authentication guide while keeping the Cache Components context. ## Verification - `pnpm prettier --with-node-modules --ignore-path .prettierignore --write docs/01-app/02-guides/authentication-with-cache-components.mdx` - Not run: full test suite (frontmatter-only documentation change) <!-- NEXT_JS_LLM -->
-
Niklas Mischkulnig authored
Enable the skipped cases in turbopack-tracing's unit.rs that pass as-is today, and document why a few of the remaining ones cannot pass with this harness. --------- Co-authored-by:vercel-fleet[bot] <308483924+vercel-fleet[bot]@users.noreply.github.com>
-