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

fix: untainted prototype access in Angular #1633

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

pauldambra
Copy link
Contributor

@pauldambra pauldambra commented Jan 18, 2025

we're seeing multiple reports of issues with the mutation observer in Safari

this is most often in relation to Angular apps

considering we recently improved detection of need to load untainted observers when using Angular

when testing locally I can always see that Safari gives a mutation observer from an iframe - but I never see that mutation observer notify of any mutations.

this PR moves back to the approach that it turns out rrweb had in V1

The Angular zone stores unpatched things that it has patched in a discoverable location. This checks for that and if it is present uses it.

This means that in practice Angular won't trigger safari to load a mutation observer from an iframe and so (in testing) reliably captures mutations in safari for angular apps

Copy link

changeset-bot bot commented Jan 18, 2025

🦋 Changeset detected

Latest commit: 7facb49

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

This PR includes changesets to release 19 packages
Name Type
@rrweb/utils Patch
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/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

@pauldambra
Copy link
Contributor Author

i think also fixes #1627

@pauldambra
Copy link
Contributor Author

customer testing shows this isn't the whole picture... will keep digging

@eoghanmurray
Copy link
Contributor

I'm sceptical about adding it to document.head (against spec?) but the sentry precedence is powerful so will approve when you are ready with any more updates.

@pauldambra
Copy link
Contributor Author

the change to head didn't fix it... or didn't fix it enough 🤣

i'm hoping the customer is still willing to test more - i think i'll try polling for the content window next to see if it's not ready when we try to read from it

it may all be a red herring here ofc 🙈

@arredgroup
Copy link
Contributor

Hi! Exists any news related to this fix? I had the same issue with dynamic iframes in my react app

@pauldambra
Copy link
Contributor Author

I need to update this PR. In the end I went back to how rrweb v1 used to do this, since Angular Zone advertises unpatched versions in a known location

Safari was perfectly capable of giving me a mutation observer from an iframe but I could never get that observer to trigger anything

@pauldambra pauldambra changed the title fix: untainted prototype access from iframe fix: untainted prototype access in Angular Jan 30, 2025
@pauldambra pauldambra marked this pull request as ready for review January 30, 2025 12:50
return defaultObj.prototype as BasePrototypeCache[T];
const isUntainted = isUntaintedAccessors && isUntaintedMethods;
// we're going to default to what we do have
let impl: BasePrototypeCache[T] =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i kept the reorganization here since I did find it difficult to track what was happening previously

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