web: drop window errors from scripts not of the page's origin (a browser's wallet or an extension), which could fail the boot

This commit is contained in:
Pooya Parsa
2026-11-28 22:31:25 +00:00
parent df6d726178
commit b9db51200e

View File

@@ -159,6 +159,18 @@
"<" + t.tagName.toLowerCase() + "> load error (404, network or MIME type)", t.tagName === "SCRIPT");
return;
}
// Scripts a browser or an extension injects (Brave's wallet touching window.ethereum, say) throw here too:
// drop an error that names no script of the page's origin (a blob: URL of it, or wasm), so it cannot fail the boot.
if (location.origin !== "null") {
let ours;
try {
const u = new URL(ev.filename);
ours = u.origin === location.origin || u.protocol === "wasm:";
} catch {
ours = String(ev.error?.stack || "").includes(location.origin);
}
if (!ours) return;
}
KW.report("exception", ev.message || "Script error", ev.error?.stack || (ev.filename ? ev.filename + ":" + ev.lineno + ":" + ev.colno : ""), !KW.started);
}, true);
addEventListener("unhandledrejection", (ev) => {