🐛 Ignore Safari browser extension errors in error handler

Add detection for Safari's webkit-masked-url:// extension URLs and filter
the "Attempting to change value of a readonly property" TypeError to prevent
Safari browser extension errors from being surfaced to users.

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
Andrey Antukh 2026-06-08 10:05:09 +00:00 committed by Alonso Torres
parent 82cfbedc26
commit eff533374d

View File

@ -436,7 +436,10 @@
(let [stack (.-stack cause)]
(and (string? stack)
(or (str/includes? stack "chrome-extension://")
(str/includes? stack "moz-extension://")))))
(str/includes? stack "moz-extension://")
;; Safari/WebKit masks extension and Web Inspector URLs
;; with this internal scheme.
(str/includes? stack "webkit-masked-url://")))))
(defn- from-posthog?
"True when the error stack trace originates from PostHog analytics."
@ -471,6 +474,14 @@
;; TypeError. This is a known Zone.js / browser-extension
;; incompatibility and is NOT a Penpot bug.
(str/starts-with? message "Cannot assign to read only property 'toString'")
;; Safari TypeError: "Attempting to change value of a readonly
;; property". Raised when browser extensions or Web Inspector
;; devtools (e.g., jsonPrune) try to mutate ClojureScript's
;; immutable data structures via Object.defineProperty.
;; ClojureScript defines getter-only properties on its maps
;; and records, making them readonly. This is NOT a Penpot bug.
(and (= (.-name ^js cause) "TypeError")
(= message "Attempting to change value of a readonly property"))
;; NotFoundError DOMException: "Failed to execute
;; 'removeChild' on 'Node'" — Thrown by React's commit
;; phase when the DOM tree has been modified externally