Skip to content

Commit 0fd3ec0

Browse files
better process handler
1 parent 5acd010 commit 0fd3ec0

File tree

1 file changed

+6
-1
lines changed
  • packages/datadog-instrumentations/src

1 file changed

+6
-1
lines changed

packages/datadog-instrumentations/src/vitest.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,22 @@ addHook({
372372
return suitePackage
373373
})
374374

375+
const processToHandler = new WeakMap()
376+
375377
addHook({
376378
name: 'tinypool',
377379
versions: ['>=1.0.0'],
378380
file: 'dist/index.js'
379381
}, (TinyPool) => {
380-
debugger
381382
// we can pass handle here to the worker, and then use it to send messages to the main process
382383
shimmer.wrap(TinyPool.prototype, 'run', run => function (_, { channel }) {
383384
const res = run.apply(this, arguments)
384385

385386
this.threads.forEach(thread => {
387+
if (processToHandler.has(thread.process)) {
388+
return
389+
}
390+
processToHandler.set(thread.process, true)
386391
thread.process.on('message', (message) => {
387392
if (message.__tinypool_worker_message__ && message.data) {
388393
workerReporterCh.publish(message.data)

0 commit comments

Comments
 (0)