feat(replay): Reset replay id from DSC on session expiry/refresh#20129
Conversation
Its possible that a user returns to an old Sentry tab, an error gets thrown and ingested w/ the expired replay id in DSC. This error then gets link in our UI because of the replay id in DSC and causes the duration to appear to be very long (>>> 1 hr). This PR adds a check in handleGlobalEvent to clear the replay id from DSC if the replay session is expired. It also updates the DSC when in session mode and replay session is refreshed.
|
This PR has been automatically closed. All non-maintainer contributions must reference an existing GitHub issue. Next steps:
Please review our contributing guidelines for more details. |
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Core
Deps
Other
Bug Fixes 🐛Core
Other
Internal Changes 🔧Core
Deps
Other
🤖 This preview updates automatically when you update the PR. |
|
folks lets remove whatever behavior is auto closing PRs this is a waste of our time for what purpose? if you want to auto close stuff it should be on a real heuristic, not just because someone didnt add boilerplate work to create ani ssue first |
|
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you apply the label |
| SESSION_IDLE_EXPIRE_DURATION, | ||
| SESSION_IDLE_PAUSE_DURATION, |
There was a problem hiding this comment.
lint: Those are unused, should address lint warnings.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2aa9c1e. Configure here.
…20686) Follow-up to a code review comment on #20129 -- this sets a replayId on the DSC when a buffer mode replay is saved and converted to a session-based replay. Normally, we attach the replay_id to a DSC using the `createDsc` hook, but only when replay is enabled and recordingMode is `session` (and not for `buffer`). https://github.com/getsentry/sentry-javascript/blob/billy/fix-dsc-after-buffer-to-session/packages/replay-internal/src/util/addGlobalListeners.ts#L40-L46 What I'm unsure of is if this does anything since we're mutating the DSC after an unknown period of time (e.g. we're in buffer mode, and an error happens after 30 minutes). ## Slop - When `sendBufferedReplayOrFlush` converts from buffer to session mode, it calls `startRecording()` directly but never updates the cached DSC with `replay_id` - The `createDsc` hook only fires for new spans, not for an already-cached DSC on the scope (set by `browserTracingIntegration`), so `replay_id` was missing from outgoing requests until a new span happened to be created - Adds `setReplayIdOnDynamicSamplingContext()` (symmetric to the existing `resetReplayIdOnDynamicSamplingContext()`) and calls it after the buffer-to-session conversion completes 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

Its possible that a user returns to an old Sentry tab, an error gets thrown and ingested w/ the expired replay id in DSC. This error then gets link in our UI because of the replay id in DSC and causes the duration to appear to be very long (>>> 1 hr). This PR adds a check in handleGlobalEvent to clear the replay id from DSC if the replay session is expired.
It also updates the DSC when in session mode and replay session is refreshed.