From 1913a6f149743db97378a7b5658fd11711240cbe Mon Sep 17 00:00:00 2001 From: Juan Fernandez Date: Fri, 25 Oct 2024 13:33:22 +0200 Subject: [PATCH] simplify --- .../dynamic-instrumentation/index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js b/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js index 06ff69c7454..ca92249dd74 100644 --- a/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +++ b/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js @@ -21,11 +21,11 @@ class TestVisDynamicInstrumentation { return [ snapshotId, new Promise(resolve => { - const id = randomUUID() - probeIdToResolvePromise.set(id, resolve) + const probeId = randomUUID() + probeIdToResolvePromise.set(probeId, resolve) this.worker.postMessage({ snapshotId, - probe: { id, file, line } + probe: { id: probeId, file, line } }) }) ] @@ -49,11 +49,12 @@ class TestVisDynamicInstrumentation { // Allow the parent to exit even if the worker is still running this.worker.unref() - this.worker.on('message', ({ id, probe, state, stack, snapshot }) => { - const resolveSnapshot = probeIdToResolvePromise.get(id) - if (resolveSnapshot) { - resolveSnapshot({ probe, state, stack, snapshot }) - probeIdToResolvePromise.delete(id) + this.worker.on('message', ({ snapshot }) => { + const { probe: { id: probeId } } = snapshot + const resolve = probeIdToResolvePromise.get(probeId) + if (resolve) { + resolve({ snapshot }) + probeIdToResolvePromise.delete(probeId) } }).unref() // We also need to unref this message handler }