Skip to content

Commit 747c642

Browse files
committed
fix(console): extra stack property is printed after the stack trace
In SpiderMonkey, when changing the `stack` property of an `Error` object, `stack` becomes an enumerable property, while V8 doesn't. Our `util.inspect`/`util.format` code was copied from Node.js, so it won't handle the difference.
1 parent a2f1d8b commit 747c642

File tree

1 file changed

+2
-1
lines changed
  • python/pythonmonkey/builtin_modules

1 file changed

+2
-1
lines changed

python/pythonmonkey/builtin_modules/util.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,9 @@ function formatValue(ctx, value, recurseTimes, ln) {
533533
base = ` ${dateToISOString.call(value)}`;
534534
} else if (isError(value)) {
535535
// Make error with message first say the error
536-
if (keyLength === 0)
536+
if (keyLength === 0 || keys.every(k => k === 'stack')) // There's only a 'stack' property
537537
return formatError(ctx, value);
538+
keys = keys.filter(k => k !== 'stack'); // When changing the 'stack' property in SpiderMonkey, it becomes enumerable.
538539
base = ` ${formatError(ctx, value)}\n`;
539540
braces.length=0;
540541
} else if (isAnyArrayBuffer(value)) {

0 commit comments

Comments
 (0)