fix(replay): Set replay_id on DSC after buffer-to-session conversion#20686
Open
fix(replay): Set replay_id on DSC after buffer-to-session conversion#20686
Conversation
When `sendBufferedReplayOrFlush` converts from buffer to session mode, it calls `startRecording()` directly but never updates the cached DSC with the new replay_id. The `createDsc` hook only fires for new spans, not for an already-cached DSC on the scope, so the replay_id was missing from all outgoing requests until a new span was created. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0dcea38 to
2e84c24
Compare
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 8f8732f. Configure here.
Contributor
size-limit report 📦
|
…onversion Verifies that a cached DSC on the scope gets replay_id set after sendBufferedReplayOrFlush converts from buffer to session mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
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.

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
createDschook, but only when replay is enabled and recordingMode issession(and not forbuffer). https://github.com/getsentry/sentry-javascript/blob/billy/fix-dsc-after-buffer-to-session/packages/replay-internal/src/util/addGlobalListeners.ts#L40-L46What 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
sendBufferedReplayOrFlushconverts from buffer to session mode, it callsstartRecording()directly but never updates the cached DSC withreplay_idcreateDschook only fires for new spans, not for an already-cached DSC on the scope (set bybrowserTracingIntegration), soreplay_idwas missing from outgoing requests until a new span happened to be createdsetReplayIdOnDynamicSamplingContext()(symmetric to the existingresetReplayIdOnDynamicSamplingContext()) and calls it after the buffer-to-session conversion completes🤖 Generated with Claude Code