Skip to content

Commit 7f3fa0b

Browse files
committed
change promise order
1 parent 4f7537d commit 7f3fa0b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/replay/src/replay.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,6 @@ export class ReplayContainer implements ReplayContainerInterface {
836836
// Only attach memory entry if eventBuffer is not empty
837837
promises.push(addMemoryEntry(this));
838838

839-
// This empties the event buffer regardless of outcome of sending replay
840-
promises.push(this.eventBuffer.finish());
841-
842839
// NOTE: Copy values from instance members, as it's possible they could
843840
// change before the flush finishes.
844841
const replayId = this.session.id;
@@ -865,7 +862,10 @@ export class ReplayContainer implements ReplayContainerInterface {
865862

866863
// NOTE: Be mindful that nothing after this point (the first `await`)
867864
// will run after when the page is unloaded.
868-
const [, , recordingData] = await Promise.all(promises);
865+
await Promise.all(promises);
866+
867+
// This empties the event buffer regardless of outcome of sending replay
868+
const recordingData = await this.eventBuffer.finish();
869869

870870
const sendReplayPromise = sendReplay({
871871
replayId,

0 commit comments

Comments
 (0)