Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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 <jasnell@gmail.com>
  • Loading branch information
BridgeAR authored and targos committed Sep 23, 2018
commit 8513b45890591c907494265204e057767bf63b90
6 changes: 4 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,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) {
Expand All @@ -841,16 +842,17 @@ function formatRaw(ctx, value, recurseTimes) {
}
}
} catch (err) {
return handleMaxCallStackSize(ctx, err, constructor, tag);
return handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl);
}
ctx.seen.pop();

return reduceToSingleString(ctx, output, base, braces);
}

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.]',
Expand Down