properly strip stack frames containing scramjet handlers

This commit is contained in:
velzie 2024-10-10 20:37:55 -04:00
parent 1dba0f8fa0
commit 29d6dadecb

View file

@ -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;