From 426925b700456e3a1656efd80b312a3c1958a364 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 7 Aug 2023 11:49:25 +0200 Subject: [PATCH] fix(replay): Cancel debounce when replay is too short/long --- packages/replay/src/replay.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/replay/src/replay.ts b/packages/replay/src/replay.ts index 18352fbf139b..1c2bddb4bc95 100644 --- a/packages/replay/src/replay.ts +++ b/packages/replay/src/replay.ts @@ -1130,6 +1130,9 @@ export class ReplayContainer implements ReplayContainerInterface { const now = Date.now(); const duration = now - start; + // A flush is about to happen, cancel any queued flushes + this._debouncedFlush.cancel(); + // If session is too short, or too long (allow some wiggle room over maxSessionLife), do not send it // This _should_ not happen, but it may happen if flush is triggered due to a page activity change or similar const tooShort = duration < this._options.minReplayDuration; @@ -1147,9 +1150,6 @@ export class ReplayContainer implements ReplayContainerInterface { return; } - // A flush is about to happen, cancel any queued flushes - this._debouncedFlush.cancel(); - // this._flushLock acts as a lock so that future calls to `_flush()` // will be blocked until this promise resolves if (!this._flushLock) {