Skip to content

fix(replay): Skip client reports for replay failures after stop#22177

Merged
mydea merged 1 commit into
developfrom
fn/fix-replay-client-reports
Jul 10, 2026
Merged

fix(replay): Skip client reports for replay failures after stop#22177
mydea merged 1 commit into
developfrom
fn/fix-replay-client-reports

Conversation

@mydea

@mydea mydea commented Jul 10, 2026

Copy link
Copy Markdown
Member

While looking into #22169, I noticed a problem with when/how we capture internal_sdk_error client reports for replays:

When a replay stops naturally for whatever reason (e.g. session expired, ...), the buffer worker is destroyed.
If any pending things happen to be in the buffer at this point, when they flush to the main process they will trigger _addEvent with an error (e.g. Worker destroyed). This would be recorded as a client report with internal_sdk_error. However, at this point replay was already stopped naturally and no client reports should be recorded for it. To make matters worse, this could lead to multiple client reports being sent at the same time (e.g. if many events are pending at the same time). This can lead to highly skewed replay outcomes.

This PR fixes this by skipping outcome generation if the replay is already stopped at this time. I am not 100% sure if this is the only problem in the linked issue but it likely is. There may be other problems with how they start/handle sessions, but that may or may not be an actual problem and is likely separate from this.

Closes #22169

@mydea mydea self-assigned this Jul 10, 2026
@mydea mydea requested a review from a team as a code owner July 10, 2026 07:03
@mydea mydea requested review from a team, Lms24, chargome and logaretm and removed request for a team July 10, 2026 07:04
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.6 kB - -
@sentry/browser - with treeshaking flags 26.04 kB - -
@sentry/browser (incl. Tracing) 46.35 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.14 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.13 kB - -
@sentry/browser (incl. Tracing, Replay) 85.62 kB +0.01% +4 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.26 kB +0.02% +8 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 90.33 kB +0.01% +6 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 102.99 kB +0.01% +4 B 🔺
@sentry/browser (incl. Feedback) 44.78 kB - -
@sentry/browser (incl. sendFeedback) 32.4 kB - -
@sentry/browser (incl. FeedbackAsync) 37.53 kB - -
@sentry/browser (incl. Metrics) 28.68 kB - -
@sentry/browser (incl. Logs) 28.93 kB - -
@sentry/browser (incl. Metrics & Logs) 29.61 kB - -
@sentry/react 29.39 kB - -
@sentry/react (incl. Tracing) 48.62 kB - -
@sentry/vue 33.03 kB - -
@sentry/vue (incl. Tracing) 48.33 kB - -
@sentry/svelte 27.63 kB - -
CDN Bundle 30 kB - -
CDN Bundle (incl. Tracing) 48.33 kB - -
CDN Bundle (incl. Logs, Metrics) 31.58 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.65 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.82 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing, Replay) 85.84 kB +0.01% +5 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.16 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.64 kB +0.01% +5 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.92 kB +0.01% +5 B 🔺
CDN Bundle - uncompressed 89.33 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.07 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.03 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.05 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.76 kB +0.03% +51 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.28 kB +0.02% +51 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.24 kB +0.02% +51 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.98 kB +0.02% +51 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.93 kB +0.02% +51 B 🔺
@sentry/nextjs (client) 51.17 kB - -
@sentry/sveltekit (client) 46.8 kB - -
@sentry/core/server 78.42 kB - -
@sentry/core/browser 64.77 kB - -
@sentry/node-core 62.73 kB - -
@sentry/node 125.33 kB +0.01% +2 B 🔺
@sentry/node (incl. diagnostics channel injection) 138.5 kB +0.01% +1 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.73 kB +0.01% +1 B 🔺
@sentry/node - without tracing 74.04 kB +0.01% +2 B 🔺
@sentry/aws-serverless 83.26 kB +0.01% +1 B 🔺
@sentry/cloudflare (withSentry) - minified 181.47 kB - -
@sentry/cloudflare (withSentry) 448.98 kB - -

View base workflow run

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good catch!

Comment thread packages/replay-internal/test/unit/util/addEvent.test.ts
@mydea mydea merged commit 04bbb79 into develop Jul 10, 2026
209 checks passed
@mydea mydea deleted the fn/fix-replay-client-reports branch July 10, 2026 07:36
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.

~50% of Session Replays getting discarded client-side (mostly Internal SDK Error, some Network Error) in Next.js app using '/tunnel' reverse proxy

2 participants