Skip to content

Commit 6bcb06c

Browse files
authored
Limit the static paths worker number during development (#45344)
As per my testing, this saves about 150~210 MB memory for the dev server as I have an 8-core CPU. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) ---------
1 parent 2335377 commit 6bcb06c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/next/src/server/dev/next-dev-server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ export default class DevServer extends Server {
126126
require.resolve('./static-paths-worker'),
127127
{
128128
maxRetries: 1,
129-
numWorkers: this.nextConfig.experimental.cpus,
129+
// For dev server, it's not necessary to spin up too many workers as long as you are not doing a load test.
130+
// This helps reusing the memory a lot.
131+
numWorkers: Math.min(this.nextConfig.experimental.cpus || 2, 2),
130132
enableWorkerThreads: this.nextConfig.experimental.workerThreads,
131133
forkOptions: {
132134
env: {

0 commit comments

Comments
 (0)