Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2545,8 +2545,11 @@ function formatPromise(ctx, value, recurseTimes) {
}

function formatExtraProperties(ctx, value, recurseTimes, key, typedArray) {
// Read the value before indenting: the getter throws for a detached
// DataView, and formatRaw() then retries with a fallback value.
const extraValue = value[key];
ctx.indentationLvl += 2;
const str = formatValue(ctx, value[key], recurseTimes, typedArray);
const str = formatValue(ctx, extraValue, recurseTimes, typedArray);
ctx.indentationLvl -= 2;

// These entries are mainly getters. Should they be formatted like getters?
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ assert.doesNotMatch(
assert.strictEqual(
util.inspect(dv),
'DataView {\n' +
' [byteLength]: 0,\n' +
' [byteOffset]: undefined,\n' +
' [buffer]: ArrayBuffer { (detached), [byteLength]: 0 }\n' +
' }',
' [byteLength]: 0,\n' +
' [byteOffset]: undefined,\n' +
' [buffer]: ArrayBuffer { (detached), [byteLength]: 0 }\n' +
'}',
);
}

Expand Down
Loading