diff --git a/packages/rrweb/src/record/observer.ts b/packages/rrweb/src/record/observer.ts index cfc17a7e79..324342e1db 100644 --- a/packages/rrweb/src/record/observer.ts +++ b/packages/rrweb/src/record/observer.ts @@ -538,6 +538,13 @@ function initStyleSheetObserver( { styleSheetRuleCb, mirror, stylesheetManager }: observerParam, { win }: { win: IWindow }, ): listenerHandler { + if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) { + // If, for whatever reason, CSSStyleSheet is not available, we skip the observation of stylesheets. + return () => { + // Do nothing + }; + } + // eslint-disable-next-line @typescript-eslint/unbound-method const insertRule = win.CSSStyleSheet.prototype.insertRule; win.CSSStyleSheet.prototype.insertRule = function (