From 29d6dadecb143fb37cf2481b2dce4c2a383abefd Mon Sep 17 00:00:00 2001 From: velzie Date: Thu, 10 Oct 2024 20:37:55 -0400 Subject: [PATCH] properly strip stack frames containing scramjet handlers --- src/client/shared/error.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/shared/error.ts b/src/client/shared/error.ts index 5051760..9494272 100644 --- a/src/client/shared/error.ts +++ b/src/client/shared/error.ts @@ -1,4 +1,4 @@ -import { decodeUrl } from "../../shared"; +import { config, decodeUrl } from "../../shared"; import { ScramjetClient } from "../client"; export const enabled = () => self.$scramjet.config.flags.cleanerrors; @@ -9,9 +9,19 @@ export default function (client: ScramjetClient, self: Self) { for (let i = 0; i < stack.length; i++) { const url = stack[i].getFileName(); + + if (url.endsWith(config.client)) { + // strip stack frames including scramjet handlers from the trace + let lines = newstack.split("\n"); + let i = lines.find((l) => l.includes(url)); + lines.splice(i, 1); + newstack = lines.join("\n"); + continue; + } + try { newstack = newstack.replaceAll(url, decodeUrl(url)); - } catch { } + } catch {} } return newstack;