Skip to content

Commit 08d983c

Browse files
committed
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. PR-URL: #22787 Reviewed-By: James M Snell <[email protected]>
1 parent 9c6f59e commit 08d983c

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
@@ -880,6 +880,7 @@ function formatRaw(ctx, value, recurseTimes) {
880880

881881
ctx.seen.push(value);
882882
let output;
883+
const indentationLvl = ctx.indentationLvl;
883884
try {
884885
output = formatter(ctx, value, recurseTimes, keys);
885886
if (skip === false) {
@@ -889,7 +890,7 @@ function formatRaw(ctx, value, recurseTimes) {
889890
}
890891
}
891892
} catch (err) {
892-
return handleMaxCallStackSize(ctx, err, constructor, tag);
893+
return handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl);
893894
}
894895
ctx.seen.pop();
895896

@@ -910,9 +911,10 @@ function formatRaw(ctx, value, recurseTimes) {
910911
return res;
911912
}
912913

913-
function handleMaxCallStackSize(ctx, err, constructor, tag) {
914+
function handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl) {
914915
if (errors.isStackOverflowError(err)) {
915916
ctx.seen.pop();
917+
ctx.indentationLvl = indentationLvl;
916918
return ctx.stylize(
917919
`[${constructor || tag || 'Object'}: Inspection interrupted ` +
918920
'prematurely. Maximum call stack size exceeded.]',

0 commit comments

Comments
 (0)