From 189d307cd104e32c4e77ed511a3bc9fd0501050f Mon Sep 17 00:00:00 2001 From: Qingyu Wang <40660121+colinaaa@users.noreply.github.com> Date: Wed, 13 Aug 2025 19:03:03 +0800 Subject: [PATCH 1/2] test: setup a maxForks to avoid "Channel closed" error --- vitest.config.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/vitest.config.ts b/vitest.config.ts index e9e99ba344..cf87e3c89a 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -2,6 +2,8 @@ // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. +import os from 'node:os'; + import { defineConfig } from 'vitest/config'; export default defineConfig({ @@ -47,6 +49,27 @@ export default defineConfig({ NODE_ENV: 'test', }, + pool: 'forks', + poolOptions: { + forks: { + maxForks: (() => + Math.floor(((cpuCount, envCPULimit) => { + if (envCPULimit) { + return envCPULimit / 2; + } else { + if (cpuCount <= 32) { + return cpuCount / 2; + } else { + return 16 + (cpuCount - 32) / 6; + } + } + })( + os.availableParallelism(), + Number.parseFloat(process.env['cpu_limit'] ?? '0'), + )))(), + }, + }, + projects: [ 'examples/*/vitest.config.ts', 'packages/react/*/vitest.config.ts', From 1e58df8e86d3a24254529871c164b235ca35baf6 Mon Sep 17 00:00:00 2001 From: Qingyu Wang <40660121+colinaaa@users.noreply.github.com> Date: Wed, 13 Aug 2025 19:44:03 +0800 Subject: [PATCH 2/2] fix: remove env cpu limit --- vitest.config.ts | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/vitest.config.ts b/vitest.config.ts index cf87e3c89a..e87048ba27 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -52,21 +52,13 @@ export default defineConfig({ pool: 'forks', poolOptions: { forks: { - maxForks: (() => - Math.floor(((cpuCount, envCPULimit) => { - if (envCPULimit) { - return envCPULimit / 2; - } else { - if (cpuCount <= 32) { - return cpuCount / 2; - } else { - return 16 + (cpuCount - 32) / 6; - } - } - })( - os.availableParallelism(), - Number.parseFloat(process.env['cpu_limit'] ?? '0'), - )))(), + minForks: 1, + maxForks: ((cpuCount) => + Math.floor( + cpuCount <= 32 + ? cpuCount / 2 + : 16 + (cpuCount - 32) / 6, + ))(os.availableParallelism()), }, },