On high-core dev machines (e.g. 28-core M-series), per-package vitest defaulted to cpus().length - 1 workers (27), and `pnpm test` ran 4 workspace packages concurrently — easily 100+ vitest threads per sweep. When the dashboard had agents running tests, 2+ concurrent sweeps would saturate CPU and the UI became sluggish. - Cap defaultMaxWorkers to min(6, cpus()-1) in cli/dashboard/desktop/ mobile/plugin-sdk vitest configs (engine and core were already capped) - Lower root `pnpm test` workspace-concurrency 4 → 2 - VITEST_MAX_WORKERS override still respected for explicit fast runs Worst-case fan-out drops from ~108 workers to ~12 per `pnpm test`. CI runners with fewer cores are unaffected (cap doesn't bind). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import { cpus } from "node:os";
|
|
import { resolve } from "node:path";
|
|
|
|
// Cap fan-out to 6 to avoid saturating high-core machines under workspace concurrency.
|
|
const defaultMaxWorkers = Math.min(6, Math.max(1, cpus().length - 1));
|
|
const requestedMaxWorkers = Number.parseInt(process.env.VITEST_MAX_WORKERS ?? String(defaultMaxWorkers), 10);
|
|
const maxWorkers = Math.max(1, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : defaultMaxWorkers);
|
|
process.env.VITEST_MAX_WORKERS = String(maxWorkers);
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
setupFiles: [resolve(__dirname, "../core/src/__test-utils__/vitest-setup.ts")],
|
|
globalSetup: [resolve(__dirname, "../core/src/__test-utils__/vitest-teardown.ts")],
|
|
testTimeout: 30_000,
|
|
hookTimeout: 30_000,
|
|
maxWorkers,
|
|
poolOptions: { threads: { minThreads: 1, maxThreads: maxWorkers }, forks: { minForks: 1, maxForks: maxWorkers } },
|
|
fileParallelism: true,
|
|
passWithNoTests: true,
|
|
projects: [
|
|
{
|
|
test: {
|
|
name: "desktop",
|
|
include: ["src/__tests__/**/*.test.ts"],
|
|
pool: "threads",
|
|
isolate: true,
|
|
},
|
|
},
|
|
{
|
|
test: {
|
|
name: "desktop-renderer",
|
|
include: ["src/renderer/**/*.test.ts", "src/renderer/**/*.test.tsx"],
|
|
environment: "jsdom",
|
|
isolate: true,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|