Skip to content

Commit

Permalink
fix: Check if recordings are still active after promise resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
zermelo-wisen committed Apr 25, 2024
1 parent 5a6afae commit a72a1e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit a72a1e7

Please sign in to comment.