We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
@@toStringTag
1 parent 83fb007 commit 42ac0c2Copy full SHA for 42ac0c2
2 files changed
lib/internal/util/inspect.js
@@ -1062,6 +1062,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
1062
ArrayPrototypePushApply(output, protoProps);
1063
}
1064
} catch (err) {
1065
+ if (!isStackOverflowError(err)) throw err;
1066
const constructorName = StringPrototypeSlice(getCtxStyle(value, constructor, tag), 0, -1);
1067
return handleMaxCallStackSize(ctx, err, constructorName, indentationLvl);
1068
@@ -1547,17 +1548,13 @@ function groupArrayElements(ctx, output, value) {
1547
1548
1549
1550
function handleMaxCallStackSize(ctx, err, constructorName, indentationLvl) {
- if (isStackOverflowError(err)) {
1551
- ctx.seen.pop();
1552
- ctx.indentationLvl = indentationLvl;
1553
- return ctx.stylize(
1554
- `[${constructorName}: Inspection interrupted ` +
1555
- 'prematurely. Maximum call stack size exceeded.]',
1556
- 'special',
1557
- );
1558
- }
1559
- /* c8 ignore next */
1560
- assert.fail(err.stack);
+ ctx.seen.pop();
+ ctx.indentationLvl = indentationLvl;
+ return ctx.stylize(
+ `[${constructorName}: Inspection interrupted ` +
+ 'prematurely. Maximum call stack size exceeded.]',
+ 'special',
+ );
1561
1562
1563
function addNumericSeparator(integerString) {
test/parallel/test-util-inspect.js
@@ -1644,6 +1644,15 @@ util.inspect(process);
1644
1645
assert.throws(() => util.inspect(new ThrowingClass()), /toStringTag error/);
1646
1647
+ const y = {
1648
+ get [Symbol.toStringTag]() {
1649
+ return JSON.stringify(this);
1650
+ }
1651
+ };
1652
+ const x = { y };
1653
+ y.x = x;
1654
+ assert.throws(() => util.inspect(x), /TypeError: Converting circular structure to JSON/);
1655
+
1656
class NotStringClass {
1657
get [Symbol.toStringTag]() {
1658
return null;
0 commit comments