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: https://github.com/nodejs/node/pull/22787 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
9c6f59ed3a
commit
08d983c3b9
@ -880,6 +880,7 @@ function formatRaw(ctx, value, recurseTimes) {
|
||||
|
||||
ctx.seen.push(value);
|
||||
let output;
|
||||
const indentationLvl = ctx.indentationLvl;
|
||||
try {
|
||||
output = formatter(ctx, value, recurseTimes, keys);
|
||||
if (skip === false) {
|
||||
@ -889,7 +890,7 @@ function formatRaw(ctx, value, recurseTimes) {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
return handleMaxCallStackSize(ctx, err, constructor, tag);
|
||||
return handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl);
|
||||
}
|
||||
ctx.seen.pop();
|
||||
|
||||
@ -910,9 +911,10 @@ function formatRaw(ctx, value, recurseTimes) {
|
||||
return res;
|
||||
}
|
||||
|
||||
function handleMaxCallStackSize(ctx, err, constructor, tag) {
|
||||
function handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl) {
|
||||
if (errors.isStackOverflowError(err)) {
|
||||
ctx.seen.pop();
|
||||
ctx.indentationLvl = indentationLvl;
|
||||
return ctx.stylize(
|
||||
`[${constructor || tag || 'Object'}: Inspection interrupted ` +
|
||||
'prematurely. Maximum call stack size exceeded.]',
|
||||
|
Loading…
x
Reference in New Issue
Block a user