Skip to content

Commit

Permalink
util: simplify inspection limit handling
Browse files Browse the repository at this point in the history
This simplifies the handling of objects that exceed 128mb. Instead
of using a separate property to identify that all following inputs
should only return their constructor name it'll just set the depth
to -1. That has the almost the same behavior as before while providing
a better output in some cases. The performance should be almost
identical as well.

PR-URL: #27733
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
BridgeAR authored and targos committed May 20, 2019
1 parent bdd75d0 commit d8b4867
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,12 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
// any proxy handlers.
const proxy = getProxyDetails(value);
if (proxy !== undefined) {
if (ctx.showProxy && ctx.stop === undefined) {
if (ctx.showProxy) {
return formatProxy(ctx, proxy, recurseTimes);
}
value = proxy[0];
}

if (ctx.stop !== undefined) {
const name = getConstructorName(value, ctx) || value[Symbol.toStringTag];
return ctx.stylize(`[${name || 'Object'}]`, 'special');
}

// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it.
if (ctx.customInspect) {
Expand Down Expand Up @@ -788,7 +783,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
// This limit also makes sure that huge objects don't block the event loop
// significantly.
if (newLength > 2 ** 27) {
ctx.stop = true;
ctx.depth = -1;
}
return res;
}
Expand Down

0 comments on commit d8b4867

Please sign in to comment.