Repository navigation
Description
Describe the bug
With test.projects, vitest run started from a terminal resolves every project with watch: true. Each project's maxWorkers then defaults to watch mode's half the cores instead of all cores but one, so test files run with about half the parallelism they get without projects, or when stdin isn't a TTY.
configDefaults.watchis!isCI && process.stdin.isTTY && !isAgent(defaults.ts).vitest runsetswatch: falsein the CLI options, butwatchisn't inPROJECT_CLI_OVERRIDES(resolveProjects.ts), so only the root config gets it.resolveTestConfigresolves each project fromdeepMerge({}, configDefaults, options)(resolveConfig.ts), so projects fall back to the default.maxWorkersdefaults from the project's ownwatch, withgetDefaultMaxWorkers(resolved.watch)(resolveConfig.ts).groupSpecsgives each group its projects'maxWorkers, and the pool runs the group with it (pool.ts,pool.ts). Browser mode'sgetThreadsCountreadsproject.config.maxWorkerstoo.
So the same command uses half the cores from a terminal, and all cores but one with a pipe as stdin, in CI, or from an agent. We ran into it while debugging browser-mode timeouts on Windows that only happened when an agent started the run: on our 32-core machine, the agent's runs got 31 workers, and runs from a terminal got 16 (Comcast/react-data-grid#4233).
Reproduction
package.json:
{
"type": "module",
"devDependencies": {
"vitest": "5.0.5"
}
}vitest.config.js:
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
reporters: ['default', './reporter.js'],
// Without `projects`, both runs use all cores but one
projects: [{ extends: true, test: { name: 'unit' } }]
}
});reporter.js:
import { availableParallelism } from 'node:os';
let running = 0;
let peak = 0;
export default class {
onInit(vitest) {
console.log(`stdin.isTTY: ${!!process.stdin.isTTY}, cores: ${availableParallelism()}`);
console.log(`root config: watch ${vitest.config.watch}, maxWorkers ${vitest.config.maxWorkers}`);
for (const project of vitest.projects) {
console.log(`project "${project.name}": watch ${project.config.watch}, maxWorkers ${project.config.maxWorkers}`);
}
}
onTestModuleStart() {
peak = Math.max(peak, ++running);
}
onTestModuleEnd() {
running--;
}
onTestRunEnd() {
console.log(`at most ${peak} test files ran at once`);
}
}And 64 test files, test/file01.test.js to test/file64.test.js, that each take a second:
import { test } from 'vitest';
test('waits', () => new Promise((resolve) => setTimeout(resolve, 1000)));npm install- Run
npx vitest runfrom a terminal. - Run
echo | npx vitest run, with a pipe as stdin.
Output on a 32-core machine, without CI or agent environment variables:
# npx vitest run
stdin.isTTY: true, cores: 32
root config: watch false, maxWorkers 31
project "unit": watch true, maxWorkers 16
Tests 64 passed (64)
Duration 4.56s (tests 98%, import 1%)
at most 16 test files ran at once
# echo | npx vitest run
stdin.isTTY: false, cores: 32
root config: watch false, maxWorkers 31
project "unit": watch undefined, maxWorkers 31
Tests 64 passed (64)
Duration 3.43s (tests 98%, import 2%)
at most 31 test files ran at once
Without projects, the run from a terminal also gets watch: false and 31 workers. It's the same on main (867a5e4).
Expected behavior
Projects follow the run's watch, so vitest run defaults to all cores but one whatever stdin is. Since watch mode applies to the whole run, resolveTestConfig could take watch from the root config, as it already does for coverage (resolveConfig.ts).
System Info
System:
OS: Windows 11 10.0.26300
CPU: (32) x64 AMD Ryzen 9 9950X3D 16-Core Processor
Memory: 42.61 GB / 63.58 GB
Binaries:
Node: 26.12.1
npm: 12.2.1
npmPackages:
vitest: 5.0.5 => 5.0.5Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Activity
github-actions commentedon Oct 25, 2026
This issue is approved, so the team accepts a pull request for it. To work on it, open a pull request against
mainand link this issue in its description with a closing keyword, for exampleFixes #11721.The team accepts one pull request per issue: if another pull request for this issue is already open, a new one is closed automatically. See our pull request policy for more context.
Run Firefox tests in parallel (#4233)
Update Vite+ to 1.5.0 and Vitest to 5.1.0 (#4277)