Skip to content

test(replay): De-flake mutationLimit large-mutations test - #24784

Merged
JPeer264 merged 2 commits into
developfrom
fix/replay-mutation-limit-flaky-test
Sep 29, 2026
Merged

JPeer264 merged 2 commits into
developfrom
fix/replay-mutation-limit-flaky-test

Conversation

@mydea

@mydea mydea commented Sep 28, 2026

Copy link
Copy Markdown
Member

The replay.mutations breadcrumb is created asynchronously — only once rrweb's MutationObserver fires — whereas the incremental snapshots and the ui.click breadcrumb are buffered synchronously on the click. Because the test's forceFlushReplay() races the force-flush triggered by stop({ reason: 'mutationLimit' }), those events can be split across two separate replay envelopes.

The test waited for the first request containing snapshots and asserted that single request held both replay.mutations and ui.click. Whenever the mutation breadcrumb landed in the second flush, that first request only carried ['ui.click'], producing the CI flake. The fix aggregates recording snapshots across requests via the existing collectReplayRequests helper, resolving once the mutation breadcrumb has arrived, so the assertions no longer depend on the flush split. Since ui.click is always buffered before the async mutation breadcrumb, it's guaranteed present in the aggregated set by then.

Root cause: flush-ordering race between the test's manual flush and replay's stop-triggered force-flush.

The `replay.mutations` breadcrumb is created asynchronously (once rrweb's
MutationObserver fires), while the incremental snapshots and `ui.click`
breadcrumb are buffered synchronously on the click. With the test's
`forceFlushReplay()` racing the force-flush from `stop({ reason:
'mutationLimit' })`, these can land in separate replay envelopes.

The test waited for the first request containing snapshots and asserted it
held both breadcrumbs, which failed whenever the mutation breadcrumb landed in
a later flush. Aggregate recording snapshots across requests via
`collectReplayRequests` until the mutation breadcrumb arrives instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 296df07. Configure here.

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 29.24 kB - -
@sentry/browser - with treeshaking flags 27.5 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.4 kB - -
@sentry/browser (incl. Tracing) 51.15 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.17 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.18 kB - -
@sentry/browser (incl. Tracing, Replay) 90.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.46 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.41 kB - -
@sentry/browser (incl. Feedback) 46.76 kB - -
@sentry/browser (incl. sendFeedback) 34.3 kB - -
@sentry/browser (incl. FeedbackAsync) 39.41 kB - -
@sentry/browser (incl. Metrics) 30.25 kB - -
@sentry/browser (incl. Logs) 30.51 kB - -
@sentry/browser (incl. Metrics & Logs) 31.18 kB - -
@sentry/react 31.08 kB - -
@sentry/react (incl. Tracing) 53.54 kB - -
@sentry/vue 36.74 kB - -
@sentry/vue (incl. Tracing) 53.7 kB - -
@sentry/svelte 29.26 kB - -
CDN Bundle 31.02 kB - -
CDN Bundle (incl. Tracing) 51.77 kB - -
CDN Bundle (incl. Logs, Metrics) 33.29 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.75 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74 kB - -
CDN Bundle (incl. Tracing, Replay) 89.36 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.53 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.5 kB - -
CDN Bundle - uncompressed 91.66 kB - -
CDN Bundle (incl. Tracing) - uncompressed 154.03 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 98.23 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 159.99 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.8 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.76 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.7 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.39 kB - -
@sentry/nextjs (client) 55.77 kB - -
@sentry/sveltekit (client) 51.59 kB - -
@sentry/core/server 39.95 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 137.15 kB +0.01% +13 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.8 kB - -
@sentry/node - without tracing 90.81 kB +0.02% +15 B 🔺
@sentry/node - without channel injection 115.51 kB +0.01% +8 B 🔺
@sentry/aws-serverless 99.08 kB +0.01% +9 B 🔺
@sentry/cloudflare (withSentry) - minified 206.62 kB - -
@sentry/cloudflare (withSentry) 514.02 kB - -

View base workflow run

… envelope

`collectReplayRequests` starts listening right after the setup
`forceFlushReplay()`, which only awaits the in-page dispatch and not the
resulting network request. A leftover in-flight envelope from the `#noop`
setup click can therefore land in the collected set and re-deliver its
`ui.click` breadcrumb, duplicating the category and breaking the exact-equality
assertion. Assert on the unique categories instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mydea
mydea marked this pull request as ready for review September 29, 2026 07:33
@mydea
mydea requested a review from a team as a code owner September 29, 2026 07:33
@mydea
mydea requested review from Lms24, logaretm and msonnb and removed request for a team September 29, 2026 07:33
@JPeer264
JPeer264 merged commit e99805e into develop Sep 29, 2026
342 of 343 checks passed
@JPeer264
JPeer264 deleted the fix/replay-mutation-limit-flaky-test branch September 29, 2026 13:34
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.

3 participants