GeezerVison is showing github.com — util: fix indentationLvl when exceeding max call stack size · nodejs/node@077e7e0
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/util.js +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -832,6 +832,7 @@ function formatRaw(ctx, value, recurseTimes) { | 832 | 832 |
| 833 | 833 | ctx.seen.push(value); | 834 | 834 | let output; | | 835 | + const indentationLvl = ctx.indentationLvl; | 835 | 836 | try { | 836 | 837 | output = formatter(ctx, value, recurseTimes, keys); | 837 | 838 | if (skip === false) { | @@ -841,16 +842,17 @@ function formatRaw(ctx, value, recurseTimes) { | 841 | 842 | } | 842 | 843 | } | 843 | 844 | } catch (err) { | 844 | | - return handleMaxCallStackSize(ctx, err, constructor, tag); | | 845 | + return handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl); | 845 | 846 | } | 846 | 847 | ctx.seen.pop(); | 847 | 848 |
| 848 | 849 | return reduceToSingleString(ctx, output, base, braces); | 849 | 850 | } | 850 | 851 |
| 851 | | -function handleMaxCallStackSize(ctx, err, constructor, tag) { | | 852 | +function handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl) { | 852 | 853 | if (errors.isStackOverflowError(err)) { | 853 | 854 | ctx.seen.pop(); | | 855 | + ctx.indentationLvl = indentationLvl; | 854 | 856 | return ctx.stylize( | 855 | 857 | `[${constructor || tag || 'Object'}: Inspection interrupted ` + | 856 | 858 | 'prematurely. Maximum call stack size exceeded.]', | |
|