-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(v9/replay): Fix re-sampled sessions after a click #17195
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
AbhiPrasad
merged 2 commits into
v9
from
billy/replay-437-buffered-replays-are-being-captured-with-no-linked-errors-v9
Jul 29, 2025
Merged
fix(v9/replay): Fix re-sampled sessions after a click #17195
AbhiPrasad
merged 2 commits into
v9
from
billy/replay-437-buffered-replays-are-being-captured-with-no-linked-errors-v9
Jul 29, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fixes a bug where an expired session-based replay will always force a new session-based replay after a click, regardless of the actual recording mode. What is happening is: - a session-based replay is left idle - user comes back and clicks on the page and triggers the click listener - [`addBreadcrumbEvent()`](https://github.com/getsentry/sentry-javascript/blob/develop/packages/replay-internal/src/coreHandlers/util/addBreadcrumbEvent.ts#L9) is called which then calls [`triggerUserActivity()`](https://github.com/getsentry/sentry-javascript/blob/develop/packages/replay-internal/src/coreHandlers/util/addBreadcrumbEvent.ts#L15) because it is a click - next, `_checkSession()` and `_refreshSession()` are called and this is where the problem starts Inside of `_refreshSession` we stop the current replay (because the session is expired), [however `stop()` is async and is `await`-ed before we re-sample](https://github.com/getsentry/sentry-javascript/blob/develop/packages/replay-internal/src/replay.ts#L917-L918). So the current replay state while `stop()` is finishing has: - `recordingMode` = `session` (initial value) - `isEnabled` = false Another however, `addBreadcrumbEvent` (and everything called until `_refreshSession`) are not async and does wait for resampling (`initializeSampling()`) to occur. This means that the click breadcrumb ends up causing a flush and always starting a new replay recording because we only check that [`recordingMode` is `buffer](https://github.com/getsentry/sentry-javascript/blob/develop/packages/replay-internal/src/replay.ts#L626)`. ## Solution When we call `stop()`, reset the `recordingMode` to `buffer` (this should be safe default as it is more restrictive behaviorally than `session`) and in `addUpdate`, add a check to see if `isEnabled()` is true (recording is enabled).
enableLogs
and beforeSendLog
option (#17092)
chargome
approved these changes
Jul 29, 2025
…ptured-with-no-linked-errors-v9
AbhiPrasad
approved these changes
Jul 29, 2025
size-limit report 📦
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the v9 backport of
#17008, which fixes a bug where an expired session-based replay will always force a new session-based replay after a click, regardless of the actual recording mode.