- 18 Aug, 2025 11 commits
-
-
nextjs-bot authored
-
Ben Gubler authored
Previously, `.next/types/validator.ts` looked like this after a build: ```typescript // Validate /Users/you/code/next.js/test/e2e/app-dir/typed-routes/app/dashboard/@team/page.tsx { const handler = {} as typeof import("/Users/you/code/next.js/test/e2e/app-dir/typed-routes/app/dashboard/@team/page.js") handler satisfies AppPageConfig<"/dashboard"> } ``` Now, it looks like this: ```typescript // Validate ../../app/dashboard/@team/page.tsx { const handler = {} as typeof import("../../app/dashboard/@team/page.js") handler satisfies AppPageConfig<"/dashboard"> } ``` This can be important for security reasons. -
Jiachi Liu authored
-
Steven authored
Testing to see if sharp works with turbopack
-
Will Binns-Smith authored
Previously, we asked users if they want to use Turbopack for `next dev`. Now, we ask if they want to use Turbopack, and if they do, we use it for both dev and build. It’s also listed as `(recommended)` like App Router. Test Plan: `pnpm build`, `./node_modules/.bin/create-next-app ~/path/to/app`. Choose the Turbopack option. Verify the app uses Turbopack for both dev and build.
-
zoomdong authored
fixed: #82106 The error was cause by the follow reason, when pass: ```ts const nextConfig: NextConfig = { /* config options here */ turbopack: { rules: { '*.txt': { loaders: ['./test-file-loader.js'], as: '*.js', }, } } }; ``` and the project directory as follows: ```bash src |_ app |_ index.tsx |_ text.txt ``` The loader will deal the `text.txt` under `src/app`, then the loader will resolve path like: ```ts require.resolve('./test-file-loader.js', paths: ['/Users/next-app/src/app']) ``` Because the resource dir the `dirname(resoucePath)`, and the resourcePath is `/Users/next-app/src/app/text.txt`, this will never resolve the right loader path here. So I just add a more `path` param(which is `contextDir`) for the require.resolve function, it will help the loader to find the right path here. -
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Niklas Mischkulnig authored
This behaves more gracefully due to eventual consistency
-
Luke Sandberg authored
Remove a debug assertion code in the `GlobalBuildInformation` implementation that was validating client references for endpoints. This was inserted as a sanity check that two traversals were doing the same thing, but this is overkill and can be trigged accidentally by an eventual consistency condition. Just drop them. If an application is edited during this computation it is possible that the module graph that GlobalBuildInformation has access to is different than the set of references that `find_server_entries` will identified, this transient condition could trigger the panic.
-
Tobias Koppers authored
### What? Fixes a race condition in the test case. Since we are using a single value for multiple Vcs (via ReadRef::cell) the counter can have multiple invalidators.
-
Tobias Koppers authored
### What? Fixes a race condition with the persisting background tasks when stopping the backend.
-
- 17 Aug, 2025 2 commits
-
-
nextjs-bot authored
-
Tobias Koppers authored
### What? - show timing event for database compaction - show timing event for persistent caching in dev too
-
- 16 Aug, 2025 6 commits
-
-
nextjs-bot authored
-
Jiwon Choi authored
-
Tobias Koppers authored
### What? Fixes a bug that breaks the pool after scaling down Closes PACK-5249
-
nextjs-bot authored
-
JJ Kasper authored
This exposes additional metadata in the server reference manifest, it is not directly used at this time though.
-
Jiwon Choi authored
fix: use `turbopack.root` value for `outputFileTracingRoot` to have consistent tracing root (#82653) Regressed from https://github.com/vercel/next.js/pull/82164 Previously, `outputFileTracingRoot` was always set via `findRoot()` if the option was not explicitly given. However, https://github.com/vercel/next.js/pull/82164 changed the behavior to run `findRoot()` only if neither `outputFileTracingRoot` nor `turbopack.root` was given. Modified to: - When BOTH options are given, ensure they match, or else WARN and use `outputFileTracingRoot`. - When EITHER option is given, map the other value as the other. - When NONE is given, call `findDir()` and use its value. - After the processes above, if the root dir value is not assigned, throw an error as a Next.js bug. Fixes https://github.com/vercel/next.js/issues/82626
-
- 15 Aug, 2025 17 commits
-
-
nextjs-bot authored
-
Benjamin Woodruff authored
The goal of this module is to avoid logging no-op build events. Turbopack uses a bottom-up execution model which leads to a lot of really short no-op "building" events that we try to filter out. If `onBuilding` isn't called before `onBuilt`, then `deferredReportHmrStartId` will be `undefined` here, causing us to report the end of a build. Since `onBuilding` wasn't called yet, the start time will be `undefined`, giving us a duration of `NaN`. We were using `deferredReportHmrStartId` to try to determine when we'd already reported the start of a build, but it wasn't quite right. Instead, use a separate, more explicit, variable for that. --- https://vercel.slack.com/archives/C046HAU4H7F/p1749456305992089?thread_ts=1749455727.004169&cid=C046HAU4H7F > we fire the BUILDING event from the server, before a client is present, then the client attaches, and eventually BUILT is sent and we trigger the NaN ms log Thanks for the root-causing help, @icyJoseph --- Tested by loading `pnpm next dev --turbopack examples/basic-css/` and modifying the source code to trigger HMRs. 
-
Alexander Kachkaev authored
Follows https://github.com/vercel/next.js/pull/81907, removes an outdated disclaimer from the docs: https://nextjs.org/docs/app/api-reference/file-conventions/middleware#runtime <img width="1346" height="852" alt="Screenshot 2025-07-30 at 00 19 01" src="https://github.com/user-attachments/assets/ebaf9d5e-4f70-4422-bda6-9801fcd52707" /> Keeping #81907 unmerged until 15.5 release would make sense, but since it’s already in, this one can go in too. Merging it after cutting 15.5.0 would also be fine. <!-- 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 # -->
-
Suneil Nyamathi authored
repro info here: https://github.com/snyamathi/nextjs-mem-leak ## Background > The Fetch Standard allows users to skip consuming the response body by relying on garbage collection to release connection resources. Undici added support for this in https://github.com/nodejs/undici/pull/3199 and later for the body of cloned responses in https://github.com/nodejs/undici/pull/3458 which first landed in [Undici version 6.19.8](https://github.com/nodejs/undici/commits/v6.19.8) in August 2024. In September 2024, this issue https://github.com/vercel/next.js/discussions/69635 was raised for the error, `TypeError: Response.clone: Body has already been consumed` In NextJS's [dedupe-fetch](https://github.com/vercel/next.js/blame/ab59e37a66f1a70b1172af9149d8aa3ba1509330/packages/next/src/server/lib/dedupe-fetch.ts#L92) the cloned response is returned to userland, while the original response is stored in a react cache ```js // match was pulled from react cache, a clone is returned to the user return match.then((response: Response) => response.clone()); ``` ## Undici Bug I'm omitting some details in the code snippet below (see full changes at https://github.com/nodejs/undici/pull/3458/files), but the Undici change to `use FinalizationRegistry for cloned response body` seems to have mixed up the response pointer and stream bodies when registering with the finalization registry, resulting in the wrong stream being cancelled. The original response, (the `match` above) stored in the react cache is cloned, and then **its** stream is registered with the finalization registry when the cloned response `newRequest` is reclaimed. **I believe this is the true underlying cause of the errors:** `Body has already been consumed` ```js function cloneBody(instance, body) { const [out1, out2] = body.stream.tee(); // Erroneously registering newRequest + old body with finalization registry streamRegistry.register(instance, new WeakRef(out1)); // Original request + out1 is used in Next's dedupe-request cache body.stream = out1; // Clone request + out2 is returned to userland return { stream: out2, }; } // When newRequest is reclaimed, the original request.body is cancelled by mistake! newRequest.body = cloneBody(newRequest, request.body); // This is what the registry looks like streamRegistry = new FinalizationRegistry((weakRef) => { const stream = weakRef.deref(); if (stream && !stream.locked && !isDisturbed(stream) && !isErrored(stream)) { stream.cancel("Response object has been garbage collected").catch(noop); } }); ``` https://github.com/snyamathi/nextjs-mem-leak/blob/main/index.mjs has a simple reproduction of this issue which shows that when the clone is reclaimed, the original stream is cancelled, leading to issues ## Memory Leak This lead to https://github.com/vercel/next.js/pull/73274 which fixed the problem by adding a custom `cloneResponse` function. https://github.com/vercel/next.js/blob/7ef0a2b2767b4159f8db8e1884bac98370528a25/packages/next/src/server/lib/clone-response.ts However, this in turn has lead to a memory leak because now there is no one to garbage collect the tee'd stream. https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/tee > To cancel the stream you then need to cancel both resulting branches. Teeing a stream will generally lock it for the duration, preventing other readers from locking it. Undici was incorrectly cancelling the stream (leading to a bug), and Next is simply not cancelling the stream (leading to a memory leak). This can be observed with a Docker setup which shows a current version of NextJS, the last version prior to the custom `cloneResponse` function, as well as the effects of the proposed fix here. <img width="2400" height="1200" alt="plot" src="https://github.com/user-attachments/assets/a1df0afd-cc8a-4a89-8c92-381ee71fff59" /> I have a reproduction available here https://github.com/snyamathi/nextjs-mem-leak/tree/main - you'll notice the memory for NextJS climb until it runs out of memory and crashes, whereas the version prior to this change (`15.0.4-canary`) is unaffected. Similarly, if we forego the dedupe cache by passing in a signal (https://github.com/vercel/next.js/blob/102f233a170e9df0b30c24a58c3953dc678ec330/packages/next/src/server/lib/dedupe-fetch.ts#L45) there is no memory leak either. The PR changes here are applied as a patch and also fix the memory leak :) ```bash docker compose pull docker compose build docker compose up -d docker container stats ``` ``` CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS 1b2f217c4d03 mem-next-og-1 28.50% 124MiB / 1GiB 12.11% 993MB / 7.45MB 0B / 0B 23 7e76622a4a3e mem-next-15.4.1-1 49.03% 1021MiB / 1GiB 99.69% 993MB / 7.5MB 0B / 0B 23 1bacb1a9b1cc mem-next-15.0.4-canary.39-1 21.22% 115.6MiB / 1GiB 11.29% 991MB / 7.44MB 0B / 0B 23 df2a8ba5800e mem-siege-1 5.59% 12.56MiB / 31.2GiB 0.04% 9.73MB / 10.5MB 0B / 0B 102 46fab210c911 mem-next-patched-1 2.46% 91.34MiB / 1GiB 8.92% 2.38MB / 1.97MB 0B / 0B 23 365987089d03 mem-upstream-1 15.16% 137.2MiB / 31.2GiB 0.43% 16.8MB / 2.97GB 0B / 0B 23 ``` Each container outputs the request number and current memory usage which are then plotted in order to observe the memory leak due to the custom `cloneResponse`. Because the fix associates the correct response and stream, the previous regression does not happen again. We can confirm this by making requests to the page for each of the docker containers. The container using the version prior to the custom `cloneResponse` will error out, while the rest will not ``` $ curl -s localhost:3002 | htmlq --text '#error' Response.clone: Body has already been consumed. ``` cc @wyattjoh @gnoff ## Reproduction https://github.com/snyamathi/nextjs-mem-leak/tree/main contains a number of reproductions - https://github.com/snyamathi/nextjs-mem-leak/blob/main/index.mjs shows a pure javascript reproduction of the original undici bug - https://github.com/snyamathi/nextjs-mem-leak/blob/main/page.js shows how that bug manifested itself in Next for the `Body has already been consumed` error - https://github.com/snyamathi/nextjs-mem-leak/blob/main/route.js shows the memory leak due to the custom `cloneResponse` function The rest of the files are supporting infrastructure to start docker containers of various versions and various patches showing how versions prior to the `cloneResponse` do not have the same memory leak, and how the patch (PR'd here) fixes the issue without regressing on the Undici issue.
-
nextjs-bot authored
-
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.
-
Tobias Koppers authored
### What? Depending on compilation mode of the react compiler, check the source code if matches a certain regex This also adds `content` as condition for webpack loaders Closes PACK-5252
-
Adem authored
Co-authored-by:Joseph <joseph.chamochumbi@vercel.com>
-
Wyatt Johnson authored
### What? Replace LRU cache implementation with an optimized doubly-linked list algorithm and move from server-only to shared library location. ### Why? The previous Map-based LRU cache had suboptimal eviction performance for route matching operations under high load. Route matching is a critical performance path in Next.js that benefits significantly from true O(1) cache operations. ### How? - Implement doubly-linked list with sentinel nodes for true O(1) get/set/delete operations - Add comprehensive test coverage including size-based eviction scenarios - Update import paths across 14 files throughout the codebase - Add defensive null checking for edge cases discovered during static analysis - Replace deprecated `keys()` iteration with modern `Symbol.iterator` pattern
-
Tobias Koppers authored
### What? Following the guideline that all CPU work should happen on a normal task.
-
Niklas Mischkulnig authored
Forgot to do this in #82652
-
Niklas Mischkulnig authored
#82641 was merged a bit soon
-
Wyatt Johnson authored
-
Joseph authored
When building w/ webpack to calculate duration, we use `process.hrtime` which is a tuple of integers [seconds, nanoseconds] - which means that for sub second compiler runs, we end up showing total 0ms, or 1000ms (I think) - https://nodejs.org/api/process.html#processhrtimetime With this PR we combine the seconds and nanoseconds into a float. ### Before: ```console ▲ Next.js 15.4.6 - Environments: .env.production Creating an optimized production build ... ✓ Compiled successfully in 0ms Skipping validation of types ``` ### After ```console ▲ Next.js 15.4.6 - Environments: .env.production Creating an optimized production build ... ✓ Compiled successfully in 813ms Skipping validation of types ```
-
Jiwon Choi authored
I added docs at https://github.com/vercel/next.js/pull/70958, but never landed on `canary` ~~due to a git rebase skill issue~~. --------- Co-authored-by:
Joseph <joseph.chamochumbi@vercel.com> Co-authored-by:
vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
-
Ben Gubler authored
Remove tests of the implementation details. Add more tests for route handler types. Re: feedback from @eps1lon
-
- 14 Aug, 2025 4 commits
-
-
JJ Kasper authored
This continues the `build-complete` handling for the adapters config adding additional prerender logic including PPR fields and expanding test coverage ensuring correct outputs.
-
Ben Gubler authored
## Add typed RouteContext for App Router route handlers This PR adds type support for route handlers in the App Router by introducing a new `RouteContext` interface. This allows for strongly-typed access to route parameters in API routes. ### Features: - Adds a new global `RouteContext<AppRouteHandlerRoute>` interface with typed `params` property - Adds test cases for various route parameter patterns - Updates type tests to verify correct type checking for route handlers This enhancement improves the developer experience by providing type safety when accessing route parameters in API route handlers, similar to the existing type support for pages and layouts.
-
nextjs-bot authored
-
Ben Gubler 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 # -->
-