Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: limit inspection output size to 128 MB #22756

Closed
wants to merge 5 commits into from
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
9 changes: 8 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ function formatValue(ctx, value, recurseTimes) {
return ctx.stylize('null', 'null');
}

if (ctx.stop) {
if (ctx.stop !== undefined) {
const name = getConstructorName(value) || value[Symbol.toStringTag];
return ctx.stylize(`[${name || 'Object'}]`, 'special');
}
Expand Down Expand Up @@ -897,6 +897,13 @@ function formatRaw(ctx, value, recurseTimes) {
const budget = ctx.budget[ctx.indentationLvl] || 0;
const newLength = budget + res.length;
ctx.budget[ctx.indentationLvl] = newLength;
// If any indentationLvl exceeds this limit, limit further inspecting to the
// minimum. Otherwise the recursive algorithm might continue inspecting the
// object even tough the maximum string size (~2 ** 28 on 32 bit systems and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tough -> though

// ~2 ** 64) exceeded. The actual output is not limited at exactly 2 ** 27 but
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~2 ** 64 -> ~2 ** 30 on 64 bit systems?

// a bit higher. This depends on the object shape.
// This limit also makes sure that huge objects don't block the event loop
// significantly.
if (newLength > 2 ** 27) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment here?

ctx.stop = true;
}
Expand Down