Skip to content

fix(replay): Set replay_id on DSC after buffer-to-session conversion#20686

Open
billyvg wants to merge 3 commits intodevelopfrom
billy/fix-dsc-after-buffer-to-session
Open

fix(replay): Set replay_id on DSC after buffer-to-session conversion#20686
billyvg wants to merge 3 commits intodevelopfrom
billy/fix-dsc-after-buffer-to-session

Conversation

@billyvg
Copy link
Copy Markdown
Member

@billyvg billyvg commented May 5, 2026

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

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>
@billyvg billyvg force-pushed the billy/fix-dsc-after-buffer-to-session branch from 0dcea38 to 2e84c24 Compare May 5, 2026 18:56
@billyvg billyvg marked this pull request as ready for review May 5, 2026 19:07
@billyvg billyvg requested a review from a team as a code owner May 5, 2026 19:07
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread packages/replay-internal/src/replay.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 26.3 kB - -
@sentry/browser - with treeshaking flags 24.78 kB - -
@sentry/browser (incl. Tracing) 44.17 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 46.39 kB - -
@sentry/browser (incl. Tracing, Profiling) 49.14 kB - -
@sentry/browser (incl. Tracing, Replay) 83.57 kB +0.03% +20 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 73.03 kB +0.03% +18 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 88.27 kB +0.04% +30 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 100.87 kB +0.03% +29 B 🔺
@sentry/browser (incl. Feedback) 43.44 kB - -
@sentry/browser (incl. sendFeedback) 31.11 kB - -
@sentry/browser (incl. FeedbackAsync) 36.19 kB - -
@sentry/browser (incl. Metrics) 27.6 kB - -
@sentry/browser (incl. Logs) 27.73 kB - -
@sentry/browser (incl. Metrics & Logs) 28.43 kB - -
@sentry/react 28.04 kB - -
@sentry/react (incl. Tracing) 46.4 kB - -
@sentry/vue 31.18 kB - -
@sentry/vue (incl. Tracing) 46.02 kB - -
@sentry/svelte 26.32 kB - -
CDN Bundle 28.91 kB - -
CDN Bundle (incl. Tracing) 46.94 kB - -
CDN Bundle (incl. Logs, Metrics) 30.34 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 48.04 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 69.42 kB +0.03% +20 B 🔺
CDN Bundle (incl. Tracing, Replay) 84.1 kB +0.04% +27 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 85.17 kB +0.04% +27 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 89.92 kB +0.03% +26 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 90.99 kB +0.03% +26 B 🔺
CDN Bundle - uncompressed 84.88 kB - -
CDN Bundle (incl. Tracing) - uncompressed 140.44 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 89.08 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 143.9 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 213.12 kB +0.06% +126 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 258.37 kB +0.05% +126 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 261.81 kB +0.05% +126 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 272.07 kB +0.05% +126 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 275.5 kB +0.05% +126 B 🔺
@sentry/nextjs (client) 48.9 kB - -
@sentry/sveltekit (client) 44.64 kB - -
@sentry/node-core 59.81 kB +0.02% +10 B 🔺
@sentry/node 163.43 kB +0.01% +6 B 🔺
@sentry/node - without tracing 72.28 kB +0.02% +8 B 🔺
@sentry/aws-serverless 106.95 kB +0.01% +5 B 🔺
@sentry/cloudflare (withSentry) - minified 168.38 kB - -
@sentry/cloudflare (withSentry) 424.9 kB - -

View base workflow run

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant