Repository navigation
|
Is there any way of using a profiler with AVA. I've tried Example error: this is the code of that file: |
Replies: 1 comment
|
The file you dug up is the whole story, and the reason it blows up is a collision over file descriptor 3. AVA copies the parent's node flags into every worker. return [...process.execArgv, ...fromConf, ...parsedArgv];and that array is handed to Now put that next to how the workers are created. With worker = childProcess.fork(fileURLToPath(workerPath), options.workerArgv, {
silent: true,
serialization: 'advanced',
...
});
The guard in that file is the giveaway: isWorker = !require('worker_threads').isMainThreadIt skips worker threads but knows nothing about forked child processes. So Rather than fight that, use the profiler that is already in Node, since it attaches to the process that actually runs your tests instead of the one that merely supervises them: That flag travels the same inheritance path, so it lands in the workers where the work happens. It also handles the default threaded mode properly — I checked on Node 24 with a script that spawns one worker, and it writes a separate profile per thread: Drop the one belonging to the test thread into Chrome DevTools or VS Code and you get the same flamegraph 0x would have drawn. If you would rather keep an external profiler, there is an escape hatch, though a narrower one than it first looks. if (workerThreads && 'filterNodeArgumentsForWorkerThreads' in conf) {so it only takes effect in threaded mode — the |
The file you dug up is the whole story, and the reason it blows up is a collision over file descriptor 3.
AVA copies the parent's node flags into every worker.
normalizeNodeArgumentsends withand that array is handed to
fork(file, options, apiOptions.nodeArguments), which passes it asexecArgvto each worker. So when 0x launches node with its-r .../redir-stdout.jspreload, that preload does not stay in the process 0x is profiling — it gets inherited by every test worker AVA starts.Now put that next to how the workers are created. With
--no-worker-threadsAVA takes this branch: