diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index b5d2d071479dec..9bb740d43befdb 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -502,7 +502,7 @@ function setEquiv(a, b, strict, memo) { for (const val of b) { // Primitive values have already been handled above. if (typeof val === 'object' && val !== null) { - if (!setHasEqualElement(set, val, strict, memo)) + if (!a.has(val) && !setHasEqualElement(set, val, strict, memo)) return false; } else if (!strict && !a.has(val) &&