Skip to content

fix(replay): Cancel debounce when replay is too short/long #8742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/replay/src/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down