Skip to content

Commit 077e7e0

Browse files
BridgeARtargos
authored andcommitted
util: fix indentationLvl when exceeding max call stack size
The inspection indentation level was not always reset to it's former value in case the maximum call stack size was exceeded. Backport-PR-URL: #23039 PR-URL: #22787 Reviewed-By: James M Snell <[email protected]>
1 parent 5a13e66 commit 077e7e0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/util.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ function formatRaw(ctx, value, recurseTimes) {
832832

833833
ctx.seen.push(value);
834834
let output;
835+
const indentationLvl = ctx.indentationLvl;
835836
try {
836837
output = formatter(ctx, value, recurseTimes, keys);
837838
if (skip === false) {
@@ -841,16 +842,17 @@ function formatRaw(ctx, value, recurseTimes) {
841842
}
842843
}
843844
} catch (err) {
844-
return handleMaxCallStackSize(ctx, err, constructor, tag);
845+
return handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl);
845846
}
846847
ctx.seen.pop();
847848

848849
return reduceToSingleString(ctx, output, base, braces);
849850
}
850851

851-
function handleMaxCallStackSize(ctx, err, constructor, tag) {
852+
function handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl) {
852853
if (errors.isStackOverflowError(err)) {
853854
ctx.seen.pop();
855+
ctx.indentationLvl = indentationLvl;
854856
return ctx.stylize(
855857
`[${constructor || tag || 'Object'}: Inspection interrupted ` +
856858
'prematurely. Maximum call stack size exceeded.]',

0 commit comments

Comments
 (0)