From c31a0b20b57ad6639c4b04ec896cc27eaf6c55bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Wed, 18 Jan 2023 15:34:47 +0200 Subject: [PATCH] fix: cpu and heap profiling options for workers (#2702) --- packages/vitest/src/node/pool.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/vitest/src/node/pool.ts b/packages/vitest/src/node/pool.ts index 9a86b9088e97..b7cb3c4da545 100644 --- a/packages/vitest/src/node/pool.ts +++ b/packages/vitest/src/node/pool.ts @@ -33,6 +33,12 @@ export function createPool(ctx: Vitest): WorkerPool { const conditions = ctx.server.config.resolve.conditions?.flatMap(c => ['--conditions', c]) || [] + // Instead of passing whole process.execArgv to the workers, pick allowed options. + // Some options may crash worker, e.g. --prof, --title. nodejs/node#41103 + const execArgv = process.execArgv.filter(execArg => + execArg.startsWith('--cpu-prof') || execArg.startsWith('--heap-prof'), + ) + const options: TinypoolOptions = { filename: workerPath, // TODO: investigate further @@ -44,13 +50,17 @@ export function createPool(ctx: Vitest): WorkerPool { execArgv: ctx.config.deps.registerNodeLoader ? [ + ...execArgv, '--require', suppressLoaderWarningsPath, '--experimental-loader', loaderPath, ...conditions, ] - : conditions, + : [ + ...execArgv, + ...conditions, + ], } if (ctx.config.isolate) {