fix error preparestacktrace can get overwritten

This commit is contained in:
velzie 2024-10-10 17:44:55 -04:00
parent 592e8d183f
commit c412959a5f

View file

@ -4,7 +4,7 @@ import { ScramjetClient } from "../client";
export const enabled = () => self.$scramjet.config.flags.cleanerrors;
export default function (client: ScramjetClient, self: Self) {
// v8 only. all we need to do is clean the scramjet urls from stack traces
Error.prepareStackTrace = (error, stack) => {
const closure = (error, stack) => {
let newstack = error.stack;
for (let i = 0; i < stack.length; i++) {
@ -16,4 +16,13 @@ export default function (client: ScramjetClient, self: Self) {
return newstack;
};
client.Trap("Error.prepareStackTrace", {
get(ctx) {
// this is a funny js quirk. the getter is ran every time you type something in console
return closure;
},
set(value) {
// just ignore it if a site tries setting their own. not much we can really do
},
});
}