Skip to content

Commit c31a0b2

Browse files
authoredJan 18, 2023
fix: cpu and heap profiling options for workers (#2702)
1 parent 0f52732 commit c31a0b2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎packages/vitest/src/node/pool.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ export function createPool(ctx: Vitest): WorkerPool {
3333

3434
const conditions = ctx.server.config.resolve.conditions?.flatMap(c => ['--conditions', c]) || []
3535

36+
// Instead of passing whole process.execArgv to the workers, pick allowed options.
37+
// Some options may crash worker, e.g. --prof, --title. nodejs/node#41103
38+
const execArgv = process.execArgv.filter(execArg =>
39+
execArg.startsWith('--cpu-prof') || execArg.startsWith('--heap-prof'),
40+
)
41+
3642
const options: TinypoolOptions = {
3743
filename: workerPath,
3844
// TODO: investigate further
@@ -44,13 +50,17 @@ export function createPool(ctx: Vitest): WorkerPool {
4450

4551
execArgv: ctx.config.deps.registerNodeLoader
4652
? [
53+
...execArgv,
4754
'--require',
4855
suppressLoaderWarningsPath,
4956
'--experimental-loader',
5057
loaderPath,
5158
...conditions,
5259
]
53-
: conditions,
60+
: [
61+
...execArgv,
62+
...conditions,
63+
],
5464
}
5565

5666
if (ctx.config.isolate) {

0 commit comments

Comments
 (0)
Please sign in to comment.