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(rrweb): external function errors should be tagged #8

Merged
merged 6 commits into from
Jun 6, 2024

Conversation

jackson-amplitude
Copy link

@jackson-amplitude jackson-amplitude commented Jun 6, 2024

Styled Components depend on the CSS related errors being thrown properly. Currently rrweb uses a Proxy to intercept calls to window.CSSStyleSheet.prototype.insertRule and a few other functions. This becomes a problem because rrweb also wraps the error handler around this call, and errors caused by external libraries calling insertRule (for example) are getting caught by rrweb handler.

This fix adds an wrapper for these function calls that happen outside of the context of rrweb, and marks the error with an _external_=true property. This allows us to differentiate the errors on the SDK and decide which errors to re-throw.

Relevant SDK change here: amplitude/Amplitude-TypeScript#763

Copy link

changeset-bot bot commented Jun 6, 2024

🦋 Changeset detected

Latest commit: 39adcd9

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

This PR includes changesets to release 8 packages
Name Type
@amplitude/rrweb Patch
@amplitude/rrweb-snapshot Patch
@amplitude/rrdom Patch
@amplitude/rrdom-nodejs Patch
@amplitude/rrweb-player Patch
@amplitude/rrweb-types Patch
@amplitude/rrweb-web-extension Patch
@amplitude/rrvideo 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

@@ -665,7 +665,9 @@ function initStyleSheetObserver(
adds: [{ rule, index }],
});
}
return target.apply(thisArg, argumentsList);
return externalFunctionWrapper(() =>
Copy link
Author

Choose a reason for hiding this comment

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

I only added this to insertRule and deleteRule since those are the ones that seem relevant for styled components. We can probably expand this further, but limiting the scope of the changes for now (though this should be fairly safe).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed could be useful for other areas that we would want to differentiate.

@jackson-amplitude jackson-amplitude merged commit d5a6553 into master Jun 6, 2024
@github-actions github-actions bot mentioned this pull request Jun 6, 2024
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.

2 participants