Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
// Iterators and the rest are split to reduce checks.
// We have to check all values in case the constructor is set to null.
// Otherwise it would not possible to identify all types properly.
if (value[SymbolIterator] || constructor === null) {
if (SymbolIterator in value || constructor === null) {
noIterator = false;
if (ArrayIsArray(value)) {
// Only set the constructor for non ordinary ("Array [...]") arrays.
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3240,3 +3240,12 @@ assert.strictEqual(
'-123_456_789.123_456_78'
);
}

// Regression test for https://github.com/nodejs/node/issues/41244
{
assert.strictEqual(util.inspect({
get [Symbol.iterator]() {
throw new Error();
}
}), '{ [Symbol(Symbol.iterator)]: [Getter] }');
}