From a72a1e7fae4b2598eab145c681bfc244a3c86efa Mon Sep 17 00:00:00 2001 From: zermelo-wisen Date: Sun, 7 Apr 2024 21:25:19 +0300 Subject: [PATCH] fix: Check if recordings are still active after promise resolution --- src/recorder.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/recorder.ts b/src/recorder.ts index 829d6460..9290ecad 100644 --- a/src/recorder.ts +++ b/src/recorder.ts @@ -76,7 +76,11 @@ export function fixReturnEventsIfPromiseResult( (value) => { const elapsed = getTime() - startTime; const promiseClass = `Promise<${getClass(value)}>`; + const currentActiveRecordings = getActiveRecordings(); recordings.map((recording, idx) => { + // If the recording is not active after promise resolution + // don't attempt to record an eventUpdate. + if (!currentActiveRecordings.includes(recording)) return; const newReturn = makeReturnEvent( returnEvents[idx].id, callEvents[idx].id, @@ -90,7 +94,11 @@ export function fixReturnEventsIfPromiseResult( }, (reason) => { const elapsed = getTime() - startTime; + const currentActiveRecordings = getActiveRecordings(); recordings.map((recording, idx) => { + // If the recording is not active after promise resolution + // don't attempt to record an eventUpdate. + if (!currentActiveRecordings.includes(recording)) return; const event = makeExceptionEvent( returnEvents[idx].id, callEvents[idx].id,