mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-27 06:43:19 +08:00
quickjs-wasi's JSException constructor runs `delete this.stack` so V8's own stack property stops shadowing the class's stack accessor; scriptc fenced the delete, so every guest exception reaching the host threw the fence error. Compiled errors keep the trace internally and class dispatch already reads the accessor, so the delete now evaluates its receiver and nothing else, for Error subclasses whose chain declares a stack getter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 lines
401 B
JavaScript
13 lines
401 B
JavaScript
// Deleting `stack` on an Error subclass that declares a stack accessor
|
|
// lets reads reach the accessor (the package's guest exceptions).
|
|
import { GuestError } from "guest-error";
|
|
|
|
try {
|
|
throw new GuestError(7);
|
|
} catch (e) {
|
|
console.log(e instanceof GuestError, e instanceof Error, e.handle, e.message);
|
|
console.log(e.stack);
|
|
e.stack = "rewritten";
|
|
console.log(e.stack, Object.keys(e));
|
|
}
|