test(replay): De-flake mutationLimit large-mutations test - #24784
Merged
Merged
Conversation
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>
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.
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.
Contributor
size-limit report 📦
|
… 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
marked this pull request as ready for review
September 29, 2026 07:33
mydea
requested review from
Lms24,
logaretm and
msonnb
and removed request for
a team
September 29, 2026 07:33
msonnb
approved these changes
Sep 29, 2026
JPeer264
approved these changes
Sep 29, 2026
47 tasks
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.

The
replay.mutationsbreadcrumb is created asynchronously — only once rrweb'sMutationObserverfires — whereas the incremental snapshots and theui.clickbreadcrumb are buffered synchronously on the click. Because the test'sforceFlushReplay()races the force-flush triggered bystop({ 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.mutationsandui.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 existingcollectReplayRequestshelper, resolving once the mutation breadcrumb has arrived, so the assertions no longer depend on the flush split. Sinceui.clickis 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.