- 17 Jul, 2025 13 commits
-
-
nextjs-bot authored
-
Maia Teegarden 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 ### 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 ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### 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 ## 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 # -->
-
Joshua Hannaford authored
fix(turbopack) Adjust the way catchall routes are handled when a more specific parallel route exists (#81634) ## Improve App Router Route Prioritization ### What? Fixed a logic bug where we were failing to correctly identify routes as catchall routes due to treating parallel routes as a completed route path. This shouldn't happen because parallel routes do not affect the routing structure. ### How? - Modified the route selection logic to more clearly prioritize specific routes over catch-all routes - Make sure we only count true leaf nodes when determining when to use the catch-all. Parallel is not a leaf node - Added a test case to ensure middleware rewrites and redirects work correctly with both parallel and non-parallel catch-all routes. Fixes #PACK-4490
-
Zack Tanner authored
When the `x-nextjs-staletime` header is sent from the server, the client router was discarding all of its staleTime heuristics (such as lastUsedTime and "reusable" cache entries). This caused an issue where after the static staleTime window expired and the prefetch data was renewed, the static staleTime itself was not being renewed. As a result, once the static staleTime expired, the client would continuously refetch the resource on every navigation, even though it had just been renewed. This removes the `x-nextjs-staleTime` logic from this heuristic because it was only intended to be considered for the new `clientSegmentCache` & cache components work
-
nextjs-bot authored
-
Wyatt Johnson authored
### What? Implements a new sortable routes system that distinguishes between source pages and rendered pages for sub-shell generation. ### Why? The existing route sorting logic in Next.js doesn't account for the distinction between the original page definition (`sourcePage`) and the final rendered route (`page`). This is critical for sub-shell generation, given this example: | Page | Source Page | |--------|--------| | `/en/[teamSlug]/[projectSlug]/monitoring` | `/[lang]/[teamSlug]/[projectSlug]/monitoring` | | `/fr/[teamSlug]/[projectSlug]/monitoring` | `/[lang]/[teamSlug]/[projectSlug]/monitoring` | | `/[lang]/[teamSlug]/~/monitoring` | `/[lang]/[teamSlug]/~/monitoring` | And a request to `/en/vercel/~/monitoring` that it will hit the `/[lang]/[teamSlug]/~/monitoring` page instead of the `/en/[teamSlug]/[projectSlug]/monitoring`. This is because we first need to sort by the Source Page and then the Page to ensure that the correct route ordering is respected. ### How? - Adds new `SortableRoute` type that tracks both `sourcePage` and `page` - Implements depth-first route comparison algorithm that properly handles segment specificity - Refactors build process to use the new sorting functions instead of legacy `getSortedRoutes` - Adds source page tracking for PPR-enabled routes with `clientSegmentEnabled` - Includes comprehensive test coverage for all route sorting scenarios The new sorting algorithm ensures consistent route ordering across builds and proper sub-shell generation behavior.
-
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 ### 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 ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### 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 ## 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 # -->
-
Niklas Mischkulnig authored
Name runtime chunks like this: `bench/basic-app/.next/static/chunks/turbopack-5356a889447ffe6d.js`
-
Benjamin Woodruff authored
## Goals - Pass through a custom `TurbopackInternalError` type when a Rust panic or an unexpected top-level `anyhow::Error` occurs. - Make a best-effort attempt to log a location of the error to telemetry. - In the case of a panic, we should have the file, line, and column where the panic occured. This could be obscured inside of a helper method, but it's better than nothing. Since this is a position in Turbopack's source code, there's zero risk of user data being included here, so it should be safe to log to telemetry. ## How it works In previous PRs, @wbinnssmith did the following: - Added a thread-local for storing the most recent panic information in Rust - Added `catch_unwind` logic to intercept the panic in turbo-tasks and read the thread-local information, with care take to make sure we're reading from the same thread (not across an `await` boundary). - Added a custom `std::error::Error` type for internal errors, with support for storing information about a source panic. - Ensured we set up `Error::source` correctly everywhere so that you can trace an error back to the root cause (presumably a panic). In #80881, I added a `NextTurbopackContext` type that we can extend to store additional helpers on. In this PR: - Adds a callback to the `Project` constructor called `throwTurbopackInternalError` that constructs and throws a custom `TurbopackInternalError`. The definition of `TurbopackInternalError` must be in JS, as we cannot reasonably define the error subclass using NAPI. - Wraps the callback in a `ThreadsafeFunction` so that it can be called in any of our async functions. - Replaces all the places we were previously converting to `napi::Error` with logic to run `throwTurbopackInternalError`. In a subsequent PR, we could move more of the panic handling into JS using `throwTurbopackInternalError`. ## Testing Added a panic and ran: ``` NEXT_TELEMETRY_DEBUG=1 pnpm next dev --turbopack examples/basic-css/ ``` <img src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/7f261d3f-351e-436a-9345-fd6e9056d20c.png" width="600">
-
Jiachi Liu authored
Update zod v3 to latest. Noticed this while playing with ai sdk as it's requires new versions of zod. Hence realized we haven't updated for a while. Bump to newer versions of `zod@3`
-
Niklas Mischkulnig authored
-
Sebastian "Sebbie" Silbermann authored
-
Jiachi Liu authored
Enable `experimental.devtoolSegmentExplorer` on canary by default and update snapshots
-
- 16 Jul, 2025 27 commits
-
-
nextjs-bot authored
-
Jiachi Liu authored
There're should be only one indicator rendered when `showIndicator` state is true, the previous condition is not correct since the previous change seem causing indicator always rendered even on SSR. since devtool bundle is also bundled on ssr layer, but the related code should not get executed. We noticed the previous condition will always render the indicator, which likely triggered some `base-ui` browser code to execute on server and crash on windows. Related #81722
-
Hendrik Liebau authored
This ensures that we show a proper error with an error stack (potentially source-mapped) when accessing `headers`/`cookies`/`draftMode` in `'use cache'`, even when caught in user-land code. For `searchParams` (currently triggering a timeout error) we'll need a slightly different solution, which will be handled in a future PR. The approach chosen here is somewhat temporary, as we'd like to implement compile-time errors instead for accessing any kind of request data in `'use cache'` functions. However, this would require a larger change to our bundlers. closes NAR-201
-
Zack Tanner authored
When we updated `experimental.strictNextHead` to be true in #65418, we did not update all spots that would default to true in the case where the value was omitted entirely. This led to the default value not being correctly applied in pages router, which resulted in duplicate metadata w/ React 19. Since we made the flag the default, we can also probably clean up this flag all together, but that can be done separately. Fixes #81655 Fixes #81689
-
Ben Gubler authored
## Update GitHub username in labeler configuration I just changed my username from "nebrelbug" to "bgub"
-
nextjs-bot authored
-
Wyatt Johnson authored
Reverts changes to the `routes-manifest.json` from #81321. Incorrect route sorting was causing some routing errors.
-
Sebastian "Sebbie" Silbermann authored
Co-authored-by:Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
-
Luke Sandberg authored
## Add a regression test for when a not-found component depends on css and triggers a bug in turbopack To correctly serve js and css resources during server side rendering we construct a client manifest that lists all the server components and their required resources. Turbopack has a bug where we fail to collect css that is used by the page if it is also used by a not-found page (and other error handlers as well). When a not-found component is present all pages pages implicitly depend on this module and depend on it as an early dependency of the generated `app-page.js` file. This means if a `not-found.js` file (or a global error file) would happen to depend on the same css as a normal component we would associate it as a client-reference of that component instead of any other. Then on a server side render we would simply omit it. This PR adds a regression test for this issue. See #77861 and #79535
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack.
-
Andrew Clark authored
Fixes an issue where opting into dynamic prefetching with prefetch={true} would not apply to head data (like the title), only the page data. Although the head was being sent by the server as part of the prefetch response, it wasn't being transferred correctly to the prefetch cache. The net result is that you can now fully prefetch a page with a dynamic title without any additional network requests on navigation. -
Andrew Clark authored
Fixes a problem with the internal `createRouterAct` testing helper where the `block: "reject"` option would not error correctly, leading to potential false negatives. I think I accidentally broke this when I added the ability to provide an array of expected responses.
-
nextjs-bot authored
-
Sebastian "Sebbie" Silbermann authored
-
nextjs-bot authored
-
Tim Neutkens authored
## What? Adds support for `remarkPlugins: ['remark-gfm']` and `rehypePlugins: ['rehype-slug']`. Previously you had to nest an array like `remarkPlugins: [['remark-gfm']]` but that's a bug, that case is only for passing options. Directly passing the string without options should be allowed. This PR implements that.
-
Wyatt Johnson authored
### What? Optimizes the `buildAppStaticPaths` function performance and extracts a helper function `calculateFallbackMode` to reduce code duplication. ### Why? The `buildAppStaticPaths` function had several performance bottlenecks: 1. **Repeated regex pattern compilation**: Route parameter patterns were being compiled inside the loop for every route, causing unnecessary overhead 2. **Inefficient root parameter lookups**: Using `Array.includes()` for root parameter checks resulted in O(n) lookups for each parameter 3. **Duplicated fallback mode logic**: The same fallback mode calculation was repeated in multiple places, making the code harder to maintain and prone to inconsistencies These inefficiencies became more apparent when processing large numbers of routes with complex parameter structures. ### How? **Performance optimizations:** - Pre-compile regex patterns for route parameters outside the loop and store them in a Map for O(1) lookups - Convert `rootParamKeys` to a Set for O(1) lookup time instead of O(n) array searches - Optimize the fallback parameter collection loop to break early and avoid redundant iterations **Code organization:** - Extract `calculateFallbackMode` helper function to eliminate code duplication - Add comprehensive tests for the new helper function to ensure correctness - Simplify the main loop logic by using the pre-compiled patterns and optimized data structures
-
Janka Uryga authored
`rootParams` was erroring if used in a `'prerender-client'`, but only if we had `fallbackRouteParams`. this is an edge case, but it is technically possible to hit if our compiler checks for using `rootParams` in client code are bypassed. i've also had to split `PrerenderStoreModern` into two types instead of having `type: 'prerender' | 'prerender-client'`. otherwise, typescript would think that the `case 'prerender'` branch wasn't enough to eliminate `PrerenderStoreModern` even though we already handled the `prerender-client` case at the top. this made the `prerenderStore satisfies never` assertion at the bottom fail. This is a bit tricky to explain, so i'm including a [TS playground repro](https://www.typescriptlang.org/play/?#code/C4TwDgpgBAysD2AnCAZCBzAhgYxFAvFAN5SiQBcUA5GMsgHYAmEiAtADYY4hUC+AUGWhwkEALLxmiegWKlwESjToQmLKlAA+1Wi1VTW2dgEtVwDQKGwEyWSORosuLddESp9fvwgAPMEmAoADMAV3psYGN4GQBnFgA3FgB5enYQABUAC2N6dAAKGJtFV2QASkpCxBz0Yn4oeqhjIKgCooA6K3wunRU1NiNTenNS2oax0kzEeAB3KHoIWYBRRCnEPKoAOXhAzHZ2GYhGRpkBsypSuoaBMZjp42BsTJbC0Q6FEaJL8agAeh+obCYOI9PR9QwmM5fcZ-KAAPSgAGFMPQqIFGPAJsYYlBMnooJgsDkADRQdIwKAsVbYu7AJ4AA3SCmoACJdAwDKchsyNFi5tsAfAALZgTCITAAI04pAxViorN6Bk4ThAzJc8tBUm5bTpULGMLy4oggJCwOm0EeRoA1ocJphAoagqIAIQXXUNQHA5Qa9SUT7fb7IYAhaRQZkAdQgVFsOXxUEFkhYMjZ+hYzLd9Wu-o90C97JYHC4uCovvT40DwZk4cj0ZkmCgSu4UGTfTT-qgme+zCCmBC7GAJbbNyKUBidqxQVM2PmiUQpb1-1hAH45w0YW11+KQoEyZj6JbsXSXsg6QDkSPInsoIbY-ZxAmQ7jbBBEjJafAQugnmaqIkKSZBTkdo2uK2xPP4MQxMYkrmkCEDYqWHbtvwAhAA) i'm guessing that `type: 'prerender' | 'prerender-client'` is more complex than a normal discriminator and TS was getting confused, which is why having two separate types solves it.
-
Jiachi Liu authored
-
Sebastian "Sebbie" Silbermann authored
-
Hendrik Liebau authored
When reading a cache entry, we usually check its tags against the recently revalidated tags, and dismiss it, if it has any of those tags. However, this is only needed during dynamic requests, specifically during the rendering that follows a revalidating server action. During the prerender validation in dev mode, we should not discard the cache entries based on the pending revalidation. The concurrently running dynamic rendering will handle discarding and recreating those cache entries. During build-time prerendering, there will never be any pending revalidated tags. This fixes a bug where a different value was rendered when revalidating with a server action and then reloading the page afterwards (or triggering another unrelated revalidating server action).
-
nextjs-bot authored
-
Hendrik Liebau authored
After having revalidated a prerendered route handler, on the subsequent request we must discard the prerendered data from the file system cache, as we already do for pages and fetch caches as well. > [!NOTE] > This PR is best reviewed with hidden whitespace changes.
-
Hendrik Liebau authored
When a server action or `'use cache'` function is defined as a synchronous function, the error message now only marks the function name for better clarity. Previously, the entire function body was marked, which looks fine in small test fixtures, but is pretty messy for larger functions, both in the terminal as well as in the dev error overlay. For anonymous default exports we can't optimize this and are still marking the entire function body, as we don't have a name to refer to. closes NAR-165
-
Hendrik Liebau authored
The `renderToString` function's last usage was removed in #78495.
-
nextjs-bot authored
Co-authored-by:Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
-