fix(test): keep local Vitest checks serialized

This commit is contained in:
Vincent Koc
2026-04-25 03:05:28 -07:00
parent 5e0cca5e24
commit 814409a3b3
8 changed files with 144 additions and 72 deletions

View File

@@ -1,6 +1,7 @@
import { spawn } from "node:child_process";
import { createRequire } from "node:module";
import path from "node:path";
import { resolveLocalVitestEnv } from "./lib/vitest-local-scheduling.mjs";
import { spawnPnpmRunner } from "./pnpm-runner.mjs";
import {
forwardSignalToVitestProcessGroup,
@@ -47,15 +48,16 @@ export function resolveVitestSpawnParams(env = process.env, platform = process.p
}
export function resolveVitestSpawnEnv(env = process.env) {
if (!shouldApplyNativeWorkerBudget(env)) {
return env;
const nextEnv = resolveLocalVitestEnv(env);
if (!shouldApplyNativeWorkerBudget(nextEnv)) {
return nextEnv;
}
const nativeWorkerCount = String(resolveNativeWorkerCount(env));
const nativeWorkerCount = String(resolveNativeWorkerCount(nextEnv));
return {
...env,
RAYON_NUM_THREADS: env.RAYON_NUM_THREADS?.trim() || nativeWorkerCount,
TOKIO_WORKER_THREADS: env.TOKIO_WORKER_THREADS?.trim() || nativeWorkerCount,
...nextEnv,
RAYON_NUM_THREADS: nextEnv.RAYON_NUM_THREADS?.trim() || nativeWorkerCount,
TOKIO_WORKER_THREADS: nextEnv.TOKIO_WORKER_THREADS?.trim() || nativeWorkerCount,
};
}