[Bug]: Error with window.CSSStyleSheet
being undefined in iframes
#1057
Labels
bug
Something isn't working
window.CSSStyleSheet
being undefined in iframes
#1057
Preflight Checklist
What package is this bug report for?
rrweb
Version
v1.1.3 (also tried 2.x, with same outcome)
Expected Behavior
An error in rrweb setup (specifically, the monkey patching of
window.CSSStyleSheet
) should be caught.Actual Behavior
Some users have reported getting these errors in their app:
Which is triggered ~ here:
rrweb/packages/rrweb/src/record/observer.ts
Line 540 in ad9bc3e
It seems quite weird to me why this is happening... After some playing around, I could pin it down to probably happening in some iframe.
I "forced" my local app via
window.CSSStyleSheet = undefined
to trigger this error, and found that in the main app it is actually handled by this code: https://github.com/rrweb-io/rrweb/blob/rrweb-snapshot%401.1.14/packages/rrweb/src/record/index.ts#L491However, once I add an iframe to the page, it is not caught by this try-catch block, as it is actually happening somewhere in a callback (I guess e.g. https://github.com/rrweb-io/rrweb/blob/rrweb-snapshot%401.1.14/packages/rrweb/src/record/index.ts#L457)
Would it make sense to wrap all occurrences of
observe()
in such a try-catch? If that makes sense, I'd be happy to try to write up a PR as well.Alternatively, I could also see value in an option to disable the parsing for (certain) iframes. As they can be a bit unpredictable and hard to control in some cases 😬
Steps to Reproduce
win.CSSStyleSheet = undefined
above this line:rrweb/packages/rrweb/src/record/observer.ts
Line 539 in 2a80949
Testcase Gist URL
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: