Skip to content

Commit

Permalink
fix: cpu and heap profiling options for workers (#2702)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Jan 18, 2023
1 parent 0f52732 commit c31a0b2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/vitest/src/node/pool.ts
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit c31a0b2

Please sign in to comment.