Skip to content

Commit d8b4867

Browse files
BridgeARtargos
authored andcommitted
util: simplify inspection limit handling
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 <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent bdd75d0 commit d8b4867

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

lib/internal/util/inspect.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -520,17 +520,12 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
520520
// any proxy handlers.
521521
const proxy = getProxyDetails(value);
522522
if (proxy !== undefined) {
523-
if (ctx.showProxy && ctx.stop === undefined) {
523+
if (ctx.showProxy) {
524524
return formatProxy(ctx, proxy, recurseTimes);
525525
}
526526
value = proxy[0];
527527
}
528528

529-
if (ctx.stop !== undefined) {
530-
const name = getConstructorName(value, ctx) || value[Symbol.toStringTag];
531-
return ctx.stylize(`[${name || 'Object'}]`, 'special');
532-
}
533-
534529
// Provide a hook for user-specified inspect functions.
535530
// Check that value is an object with an inspect function on it.
536531
if (ctx.customInspect) {
@@ -788,7 +783,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
788783
// This limit also makes sure that huge objects don't block the event loop
789784
// significantly.
790785
if (newLength > 2 ** 27) {
791-
ctx.stop = true;
786+
ctx.depth = -1;
792787
}
793788
return res;
794789
}

0 commit comments

Comments
 (0)