From 6bdfd7280923dfc9a706119d96196c01c09c086d Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Fri, 4 Sep 2026 21:29:04 +0800 Subject: [PATCH] perf(test): raise local vitest workers to 8 with 10s timeout The 4-worker cap existed only to keep deferred-promise tests inside Vitest's old 5s default when several workers pay the first dynamic import of the large store modules at once; a 10s testTimeout absorbs that without capping throughput. CI keeps 4 workers (4-vCPU runners already share CPU with vue-tsc/oxlint/oxfmt via pnpm check). Also add pnpm test:watch for incremental local runs. --- package.json | 1 + vitest.config.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9f253442f2..29c7f24cfd 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "fmt": "oxfmt \"apps/desktop/src/**/*.{ts,vue}\"", "pretest": "pnpm generate:connection-types", "test": "vitest run", + "test:watch": "vitest", "preview": "vite preview --config apps/desktop/vite.config.ts", "tauri": "tauri", "prepare": "husky" diff --git a/vitest.config.ts b/vitest.config.ts index 27aba5d20f..91bbb1089f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -13,9 +13,14 @@ export default defineConfig({ test: { include: ["packages/app-tests/*.test.ts", "apps/desktop/src/**/*.spec.ts", "docs/lib/*.test.ts"], globalSetup: "packages/test-globals.ts", - // Large store modules are dynamically imported in many specs. Limiting - // concurrency prevents those imports from starving timers and making - // otherwise deterministic deferred-promise tests exceed Vitest's timeout. - maxWorkers: 4, + // Many specs dynamically import the large store modules (connectionStore, + // queryStore) inside test bodies; when several workers pay that first + // import at once, CPU contention can stall a worker's event loop past the + // old 5s default and flake deferred-promise tests. A 10s timeout absorbs + // that without capping throughput, so workers can scale past 4. CI keeps + // 4 workers: its 4-vCPU runners already run vue-tsc/oxlint/oxfmt + // concurrently with vitest via `pnpm check`. + testTimeout: 10_000, + maxWorkers: process.env.CI ? 4 : 8, }, });