- 18 Jul, 2025 20 commits
-
-
nextjs-bot authored
-
Jiwon Choi authored
This PR adds a pending state to the clear bundler cache & server restart. When the user clicks the restart server button, Next.js fetches `/__nextjs_server_status` for the current server's execution ID. Then it queries `/__nextjs_restart_dev` middleware to trigger the server restart, then polls the `/__nextjs_server_status` path to confirm the server execution ID differs, which means the new server is online. When the server has restarted, reload the window. Closes NEXT-4562 Closes NEXT-4501 --------- Co-authored-by:Jiachi Liu <inbox@huozhi.im>
-
Wyatt Johnson authored
### What? This PR fixes an issue where pages with fallback route params weren't triggering dynamic resume behavior in PPR (Partial Pre-Rendering). ### Why? When fallback route params exist, the RSC (React Server Components) data is inherently dynamic because the params are encoded into the flight router state. Without this fix, pages with fallback route params would incorrectly be treated as fully static, leading to incorrect behavior. ### How? - Added a check in `app-render.tsx` to ensure that pages with fallback route params (`workStore.fallbackRouteParams.size > 0`) always perform a dynamic resume after the static prerender - Refactored PPR tests to use deterministic sentinel markers (`<\!-- PPR_BOUNDARY_SENTINEL -->`) instead of time-based measurements for more reliable testing - Updated the test utilities to split responses based on the sentinel marker rather than timing delays This ensures that: 1. Pages with fallback route params correctly trigger dynamic behavior 2. PPR tests are more reliable and deterministic 3. The boundary between static and dynamic content is clearly marked in test mode Fixes #
-
Jiachi Liu authored
* The scrollbar styling was lost before while we enabling the draggable panel. Share that styles between all scrollable content * Migrate the inline style to css and dynamic css into css variables, so we'll create less dynamic object during rendering. <video src="https://github.com/user-attachments/assets/df63169f-4846-4c53-91b4-3ca0585dd76d" width="400">
-
Jiachi Liu authored
Hide the segment explorer menu item in pages router Closes NEXT-4635
-
Luke Sandberg authored
## Use `require` to load chunks in node instead of readFile+eval The benefit of this is that we can slightly simplify chunk loading and make it easier for hosting services to cache bytecode. Much like [browsers](https://v8.dev/blog/code-caching-for-devs), server environments often leverage VM features to cache parsed javascript as bytecode (or maybe binary ast?) to accelerate cold starts ([example](https://vercel.com/blog/introducing-bytecode-caching-for-vercel-functions)), however, these systems generally avoid caching highly dynamic content like inline scripts and `eval` parameters. So just use `require` which is what platforms expect! This should help platforms achieve code caching, is generally simpler, and by not adding a prefix we fix some subtle off-by-one issue with source maps. A slightly better solution imho would be `import()` since it would enable node to do some file reading parsing async with the main thread which could be important if there are multiple `preloadModules`, however this breaks dev mode hot reloading. Fixes #PACK-5062
-
rauno authored
This PR resolves NEXT-4610 by using `e.code` over `e.key` in both storing and detecting keyboard shortcuts. Consider this problematic keybind: Alt + L If we capture `e.key` here then it will correspond to a glyph (¬) because pressing Alt + L creates this character. While `e.code` will give us `KeyL` as the value which we also later use in `useShortcuts()` to match the keybind correctly without having to detect glyphs. --- After this PR: https://github.com/user-attachments/assets/222fc65f-7320-4487-b387-ea263acfe387
-
Jiachi Liu authored
css reset component can stay in global.css now, no need to keep it as inline css component
-
nextjs-bot authored
-
Hendrik Liebau authored
The places in which we called `getExpectedRequestStore()` were already narrowing down the work unit store type to a request store. This allows us to delete the function, and call `throwForMissingRequestStore()` directly instead.
-
Niklas Mischkulnig authored
-
Hendrik Liebau authored
Showing compilation errors for files that aren't currently open is very useful during refactorings. https://github.com/user-attachments/assets/629f8f2a-37ba-44c1-be6d-9a2e0f93e4f1
-
Sebastian "Sebbie" Silbermann authored
-
nextjs-bot authored
Co-authored-by:Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
-
Hendrik Liebau authored
We are using hanging promises for excluding request-specific data from a prerender. When prerendering is aborted, we reject all hanging promises. In dev mode, React uses these rejections to construct more detailed owner stacks. This allows us to provide better errors during the prerender validation. For this to work reliably, we need to ensure that all hanging promises are rejected after React's rendering is aborted. However, some hanging promises are created before React starts rendering (when creating the RSC component tree). Furthermore, for memory reasons, the first hanging promise adds a single abort listener that's shared with all subsequent hanging promises (see #77480). In this case, the shared abort listener for rejections is added before React can add its own abort listener. When using the same abort signal for both the React render and the hanging promises, the hanging promises would be rejected too early, preventing React from properly constructing the owner stacks. To ensure that the order of operations is correct, we now use a separate abort signal for React's rendering that is aborted before the "render signal" [^1], which is used by the hanging promises, is aborted. For parity, we're doing this not only in dev mode but also in production mode, so that the hanging promise rejection handling is always the same. Technically, I don't think this change is necessary for the SSR prerender pass, but it felt cleaner to apply it there as well. However, we could revisit that when we properly split the two prerender stores. For example, the `cacheSignal` and `prerenderResumeDataCache` also don't need to be present on the client prerender store. Reverts #81501. [^1]: This is an unfortunate name clash. We could also call this one "cache signal", which would be in line with `React.cacheSignal()` – its potential successor. But that clashes with our current `cacheSignal`, which tracks the cache reads. We might revisit this naming problem in a future PR.
-
Wyatt Johnson authored
## What? Rename `experimental.dynamicIO` to `experimental.cacheComponents` across the Next.js codebase. ## Why? We're going to be merging the functionality of the `ppr`, `dynamicIO` and `useCache` experimental flags into the singular `cacheComponents` flag to reduce complexity of the codebase and simplify adoption for users wanting to experiment with experimental features. ## How? - Renamed the configuration option from `experimental.dynamicIO` to `experimental.cacheComponents` - Added deprecation handling with automatic migration for the old option name - Updated all documentation, tests, and internal references - Updated Rust code in SWC transforms and Turbopack - Maintained backward compatibility with deprecation warnings NAR-158
-
Wyatt Johnson authored
### What? This PR adds a `sourcePage` property to dynamic routes in the routes manifest to provide the necessary context for lambda creation during the build process when PPR is enabled. ### Why? The build process was missing the required context to properly create lambdas for dynamic routes when PPR is enabled. Without the source page information, the build couldn't determine which page a dynamic route originated from, preventing correct lambda generation. ### How? - Added a new `DynamicManifestRoute` type that extends `ManifestRoute` with an optional `sourcePage` property - Updated the `pageToRoute` function with overloads to pass the source page context - Modified the routes manifest generation to include the source page when creating dynamic routes for PPR-enabled pages - The `sourcePage` property is only populated for app pages when PPR is enabled (remains `undefined` for regular dynamic routes) This ensures the build process has the necessary context to create the underlying lambdas correctly.
-
Benjamin Woodruff authored
I originally split this off to support #81742, but I ended up rewriting that PR to not depend on this... However, I think this is still a code quality improvement, so I'm publishing the PR anyways. A few notable changes: - This is now three traits (`DynPartialEq`, `DynEq`, and `DynHash`) instead of one (`DynamicEqHash`) - The `Dyn` naming instead of `Dynamic` matches the more common Rust convention. - [Trait upcasting is finally stable!](https://blog.rust-lang.org/2025/04/03/Rust-1.86.0/#trait-upcasting) Remove the `.as_any()` idiom. Be very careful with the explicit derefs. - Fix a bug where the type id was getting added to the hash state twice (once by the `Hash` impl, and a second time by the `DynHash` impl). - The `HasherMut` struct isn't really needed, as you can use a `&mut &mut Hasher` instead to work around these dyn compatibility issues in the stdlib. And finally, `MagicAny` is ported to use these `Dyn` traits to dedupe some logic.
-
Jiachi Liu authored
Change the copy button's content from the original error stack trace to a prompt template with error details from the error page and ask AI to fix it. You can copy it for either bug reporting or asking AI agent to explain/fix the errors for you. ### Example content A runtime error prompt ``` Fix this error in Next.js app: ## Error Type Runtime Error ## Error Message Error on client at Page (app/runtime-error/page.tsx:5:11) ## Code Frame 3 | export default function Page() { 4 | if (typeof window !== 'undefined') { > 5 | throw new Error('Error on client') | ^ 6 | } 7 | return <p>page</p> 8 | } Next.js version: 15.4.2-canary.3 (Webpack) Explain what's wrong and fix it. ``` ### Recordings | build error | runtime error | |:--|:--| | <video src="https://github.com/user-attachments/assets/f31c935e-797c-48c7-8e80-5c1bdcde7c5c"> | <video src="https://github.com/user-attachments/assets/15987538-af32-4a32-90e7-1bbf08f1d57b"> | -
Jiachi Liu authored
Since we have global css reset, we can only need to reset the font style once, not everywhere Closes NEXT-4628
-
- 17 Jul, 2025 15 commits
-
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack.
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
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 5 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"
-