mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-29 07:04:09 +08:00
zod 4 saves and restores the limit through an alias, `const E = "captureStackTrace" in Error ? Error : null`. The interned Error constructor value now answers `stackTraceLimit` from the same limit the static member and stack capture use, and numeric writes set it, so `E.stackTraceLimit` reads 10 instead of undefined and `E.stackTraceLimit = 0` reaches `Error.stackTraceLimit`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
744 B
JavaScript
19 lines
744 B
JavaScript
// Error.stackTraceLimit through the Error constructor held as a value
|
|
// (zod 4's `const E = "captureStackTrace" in Error ? Error : null`): reads
|
|
// and writes reach the same limit as the static member.
|
|
const E = "captureStackTrace" in Error ? Error : null;
|
|
console.log(typeof E, E === Error, E.stackTraceLimit, Error.stackTraceLimit);
|
|
const saved = E.stackTraceLimit;
|
|
E.stackTraceLimit = 0;
|
|
console.log(Error.stackTraceLimit, E.stackTraceLimit, typeof saved === "number");
|
|
console.log(new Error("no frames").stack);
|
|
try {
|
|
E.stackTraceLimit = 3;
|
|
console.log(Error.stackTraceLimit);
|
|
} finally {
|
|
E.stackTraceLimit = saved;
|
|
}
|
|
console.log(E.stackTraceLimit, Error.stackTraceLimit);
|
|
Error.stackTraceLimit = 4;
|
|
console.log(E.stackTraceLimit);
|