Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [RUM-2280] fix duplicated mutations when using Shadow DOM #2527

Merged

Conversation

BenoitZugmeyer
Copy link
Member

@BenoitZugmeyer BenoitZugmeyer commented Dec 11, 2023

Motivation

Shadow Roots need to be instrumented with a MutationObserver and an input event listener to properly generate incremental snapshots for changes happening inside of them. We do this instrumentation during serialization.

The issue is, when serializing the same Shadow Root multiple times (ex: when a route_change view is created and a second Full Snapshot is taken), Shadow Roots are instrumented multiple times, so inner incremental snapshots are generated multiple times whenever a single change is done.

Changes

Make sure we instrument Shadow Roots only once

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@BenoitZugmeyer BenoitZugmeyer requested review from a team as code owners December 11, 2023 17:54
@@ -311,6 +311,22 @@ describe('record', () => {
expect(innerMutationData.isChecked).toBe(true)
})

it('should record the change event inside a shadow root only once, regardless if the DOM is serialized multiple times', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test is on input events, as it is easier to test. Mutations are asynchronous and since the original "Shadow Root Controller" was replaced by a new one, calling flushMutations() did not flush both of them.

Anyway, one test should be enough to avoid regression.

@BenoitZugmeyer
Copy link
Member Author

/to-staging

@dd-devflow
Copy link
Contributor

dd-devflow bot commented Dec 11, 2023

⚠️ Devflow

to-staging is not enabled on this repository.

If you need support, contact us on slack #ci-interfaces!

@BenoitZugmeyer
Copy link
Member Author

/to-staging

@dd-devflow
Copy link
Contributor

dd-devflow bot commented Dec 12, 2023

🚂 Branch Integration: starting soon, merge in < 0s

Commit db65956ab2 will soon be integrated into staging-50.

This build is going to start soon! (estimated merge in less than 0s)

you can cancel this operation by commenting your pull request with /to-staging -c!

@dd-devflow
Copy link
Contributor

dd-devflow bot commented Dec 12, 2023

⚠️ Branch Integration: This commit was already integrated

Commit db65956ab2 had already been merged into staging-50

If you need support, contact us on slack #ci-interfaces!

Copy link
Contributor

@ThibautGeriz ThibautGeriz left a comment

Choose a reason for hiding this comment

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

LGTM

@BenoitZugmeyer BenoitZugmeyer merged commit fe2f11c into main Dec 12, 2023
18 checks passed
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/fix-shadow-dom-duplicate-incremental-snapshot branch December 12, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants