Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cpu and heap profiling options for workers #2702

Merged
merged 1 commit into from Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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