From ece434a38c00eb9f8c09df74f03c6875f669ca97 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 11 Jan 2023 17:30:29 +0100 Subject: [PATCH] fix: terminate workers, when closing process (#2645) * feat: destroy workers, when closing process * chore: terminate all workers when closing pool --- packages/vitest/src/node/pool.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vitest/src/node/pool.ts b/packages/vitest/src/node/pool.ts index 457d65cac2c0..6561b2436edd 100644 --- a/packages/vitest/src/node/pool.ts +++ b/packages/vitest/src/node/pool.ts @@ -127,7 +127,9 @@ export function createPool(ctx: Vitest): WorkerPool { return { runTests: runWithFiles('run'), - close: async () => {}, // TODO: not sure why this will cause Node crash: pool.destroy(), + close: async () => { + await Promise.all(pool.threads.map(w => w.terminate())) + }, } }