From df55dc9fc693179724609ae503bbea8c5a778efe Mon Sep 17 00:00:00 2001 From: velzie Date: Fri, 9 Aug 2024 17:09:02 -0400 Subject: [PATCH] catch promise rejections --- src/client/shared/wrap.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/client/shared/wrap.ts b/src/client/shared/wrap.ts index 3525ef6..5f50d4e 100644 --- a/src/client/shared/wrap.ts +++ b/src/client/shared/wrap.ts @@ -97,4 +97,15 @@ export default function (client: ScramjetClient, self: typeof globalThis) { argdbg(t); return t; }; + + client.Proxy("Promise.prototype.catch", { + apply(ctx) { + ctx.args[0] = new Proxy(ctx.args[0], { + apply(target, thisArg, argArray) { + console.warn("CAUGHT PROMISE REJECTION", argArray); + Reflect.apply(target, thisArg, argArray); + }, + }); + }, + }); }