fix(js): console.log(Error) must not trigger Error.prepareStackTrace
deviceandbrowserinfo.com detects CDP by setting Error.prepareStackTrace as a spy, then calling console.log(new Error()). _consoleFn accessed a.stack, which fires prepareStackTrace if set. Fix: save/clear/restore around the .stack access.
This commit is contained in:
1 parent
534de77882
commit
3c92c36862
2 files changed
+22
-1
No files matched your search
Vendored
+7
-1
@@ -212,7 +212,13 @@ const _consoleFn = (level, args) => {
|
||||
try { Deno.core.ops.op_console_msg(level, args.map(a => {
|
||||
if (a === null) return "null";
|
||||
if (a === undefined) return "undefined";
|
||||
if (a instanceof Error) return a.stack || a.message || String(a);
|
||||
if (a instanceof Error) {
|
||||
const _pst = Error.prepareStackTrace;
|
||||
if (_pst !== undefined) Error.prepareStackTrace = undefined;
|
||||
const _s = a.stack || a.message || String(a);
|
||||
if (_pst !== undefined) Error.prepareStackTrace = _pst;
|
||||
return _s;
|
||||
}
|
||||
if (typeof a === "object") {
|
||||
try {
|
||||
const s = JSON.stringify(a);
|
||||
|
||||
Reference in new issue
Block a user