mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(web-runtime): guard global error listeners for non-browser hosts
The module registered window error/unhandledrejection listeners at top level, which threw under Node (the spec-api test runner) where globalThis.addEventListener is absent. Register only when the API exists; the real browser run is unaffected.
This commit is contained in:
1 parent
95d64d6452
commit
c41e4d0195
1 file changed
+8
-6
@@ -339,12 +339,14 @@ function recordException(error: unknown): void {
|
||||
});
|
||||
}
|
||||
|
||||
globalThis.addEventListener("error", (event: ErrorEvent) => {
|
||||
recordException(event.error ?? event.message);
|
||||
});
|
||||
globalThis.addEventListener("unhandledrejection", (event: PromiseRejectionEvent) => {
|
||||
recordException(event.reason);
|
||||
});
|
||||
if (typeof globalThis.addEventListener === "function") {
|
||||
globalThis.addEventListener("error", (event: ErrorEvent) => {
|
||||
recordException(event.error ?? event.message);
|
||||
});
|
||||
globalThis.addEventListener("unhandledrejection", (event: PromiseRejectionEvent) => {
|
||||
recordException(event.reason);
|
||||
});
|
||||
}
|
||||
|
||||
function buildState(): unknown {
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user