From 033d526f9f3f50e8e4f0038dbc0bac771daa281d Mon Sep 17 00:00:00 2001 From: Yaowei Zheng Date: Mon, 27 Jul 2026 23:16:20 +0800 Subject: [PATCH] fix(server): harden test cleanup and deadlines for Windows runners (#88) Co-authored-by: Claude Fable 5 --- packages/server/test/helpers.ts | 6 +++++- packages/server/vitest.config.ts | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 packages/server/vitest.config.ts diff --git a/packages/server/test/helpers.ts b/packages/server/test/helpers.ts index e77c1b2..b8b9b2a 100644 --- a/packages/server/test/helpers.ts +++ b/packages/server/test/helpers.ts @@ -66,7 +66,11 @@ export async function createTestApp(options: TestAppOptions = {}): Promise { deps.channels.dispose(); deps.db.close(); - await fs.rm(root, { recursive: true, force: true }); + // maxRetries: Windows can report ENOTEMPTY/EBUSY while handles from the test's own + // just-closed files (SQLite, trace writers) are still being released — Node's rm + // retries these codes with a delay. A plain rm was the top cause of ci-windows + // cascades (cleanup throws → hook timeout → "database is not open" in later files). + await fs.rm(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }); }, }; } diff --git a/packages/server/vitest.config.ts b/packages/server/vitest.config.ts new file mode 100644 index 0000000..f16ba7e --- /dev/null +++ b/packages/server/vitest.config.ts @@ -0,0 +1,19 @@ +/** + * Vitest config for the server. Mirrors core's platform-aware deadline rationale: these + * tests build full app instances over real SQLite files and Agent State trees, and the + * Windows CI runners' I/O variance (Defender first-touch scans, slow handle release) + * pushes individually fast tests and cleanup hooks past the 5s/10s defaults — a + * different file on each run. Larger deadlines change nothing for passing tests; POSIX + * keeps the defaults to fail fast during local development. The hook timeout matters + * here specifically: `cleanup()` removes the whole test root, and on win32 that rm can + * legitimately take retries (see helpers.ts). + */ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + environment: "node", + testTimeout: process.platform === "win32" ? 30_000 : 5_000, + hookTimeout: process.platform === "win32" ? 30_000 : 10_000, + }, +});