From 987d58ba354c78a49f295217e745c1c3f5d9251e Mon Sep 17 00:00:00 2001 From: Krzysztof Grziwok Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] Catch Security Errors in styleSheet rules (#437) --- .gitignore | 1 + src/replay/index.ts | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 72d4650b..ceafb636 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode +.idea node_modules package-lock.json # yarn.lock diff --git a/src/replay/index.ts b/src/replay/index.ts index 6f2f7a60..700bef19 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -849,16 +849,23 @@ export class Replayer { if (d.adds) { d.adds.forEach(({ rule, index }) => { - const _index = - index === undefined - ? undefined - : Math.min(index, styleSheet.rules.length); try { - styleSheet.insertRule(rule, _index); + const _index = + index === undefined + ? undefined + : Math.min(index, styleSheet.rules.length); + try { + styleSheet.insertRule(rule, _index); + } catch (e) { + /** + * sometimes we may capture rules with browser prefix + * insert rule with prefixs in other browsers may cause Error + */ + } } catch (e) { /** - * sometimes we may capture rules with browser prefix - * insert rule with prefixs in other browsers may cause Error + * accessing styleSheet rules may cause SecurityError + * for specific access control settings */ } });