Skip to content

fix: remote CSS does not get rebuilt properly#1618

Merged
YunFeng0817 merged 4 commits intorrweb-io:masterfrom
getsentry:fix-snapshot-remote-css-rebuild
Jan 20, 2025
Merged

fix: remote CSS does not get rebuilt properly#1618
YunFeng0817 merged 4 commits intorrweb-io:masterfrom
getsentry:fix-snapshot-remote-css-rebuild

Conversation

@billyvg
Copy link
Contributor

@billyvg billyvg commented Jan 6, 2025

This fixes an issue where inlined CSS from a remotely loaded <link> does not get applied properly due to object reference mutation.

This fixes an issue where inlined CSS from a remotely loaded `<link>` does not get applied properly due to object reference mutation.
@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2025

🦋 Changeset detected

Latest commit: f398551

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
rrweb Patch
rrweb-snapshot Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/all Patch
@rrweb/replay Patch
@rrweb/record Patch
@rrweb/types Patch
@rrweb/packer Patch
@rrweb/utils Patch
@rrweb/web-extension Patch
rrvideo Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eoghanmurray
Copy link
Contributor

I can't make changes directly on this branch;

Would you be able to

  • add a changeset
  • cherry-pick the following commit so that the tests pass: c8b0595

@eoghanmurray
Copy link
Contributor

The Object.assign bit was introduced in #995
I'm wondering if it had special significance there in terms of how the link element is updated ... have pinged Yun.

@YunFeng0817
Copy link
Member

@billyvg The only difference is that Object.assign overwrites the attribute value in the mirror. Your change does not change the meta in the mirror.
Can you please help me understand why this difference can cause the bug?

@billyvg
Copy link
Contributor Author

billyvg commented Jan 14, 2025

@YunFeng0817 Yeah so I'm not sure if we are relying on changing the meta in the mirror elsewhere. The reason for this change is as follows:

@YunFeng0817
Copy link
Member

@billyvg Thank you for the clean explanation. I now understand the cause of the issue.
buildNodeWithSN() is called with the meta from mirror I made this for preventing duplicate nodes in the replayer. But a remotely loaded is an exception for the check.

Can you add

Object.assign(
  newSn.attributes,
  mutation.attributes as attributes,
);

to the place after the newNode is created? This can keep the mirror sync with Dom status

@billyvg
Copy link
Contributor Author

billyvg commented Jan 20, 2025

@YunFeng0817 Updated!

Copy link
Member

@YunFeng0817 YunFeng0817 left a comment

Choose a reason for hiding this comment

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

LGTM

@YunFeng0817 YunFeng0817 merged commit 79837ac into rrweb-io:master Jan 20, 2025
billyvg added a commit to getsentry/rrweb that referenced this pull request May 9, 2025
* fix: remote CSS does not get rebuilt properly

This fixes an issue where inlined CSS from a remotely loaded `<link>` does not get applied properly due to object reference mutation.

* add changeset

* ci-cd on ubuntu-22.04 instead of latest

* keep mirror meta synced
pauldambra added a commit to PostHog/posthog-rrweb that referenced this pull request Mar 24, 2026
## Changes

Adopts upstream rrweb [PR #1618](rrweb-io/rrweb#1618).

When replaying attribute mutations on `<link>` elements with remote CSS, `buildNodeWithSN()` was called after `Object.assign()` mutated the mirror's attribute references in-place. This caused subsequent checks to fail because the mirror's metadata had been overwritten.

Fix: call `buildNodeWithSN()` first with a spread copy of the attributes, then mutate `newSn.attributes` afterward to keep the mirror in sync without affecting the build step.

Part of #147.
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