Repository navigation
[Node v20] assert.deepEqual doesn't detect two different URLs #50836
Description
Activity
marco-ippolito commented
on Nov 21, 2023 on Nov 21, 2023 · Hidden as resolvedshow commentMore actions- changed the title
[-][Node v20] assert.deepEqual doesn't detect two different URLs[/-][+][Node v18] assert.deepEqual doesn't detect two different URLs[/+]on Nov 21, 2023 The two URLs are different.
- With Node v18,
assert.deepEqualshows that there is a difference. - With Node v20,
assert.deepEqualdoesn't return an error, although the URLs aren't equal.
It works in v18 and the bug is in v20.
- With Node v18,
- changed the title
[-][Node v18] assert.deepEqual doesn't detect two different URLs[/-][+][Node v20] assert.deepEqual doesn't detect two different URLs[/+]on Nov 21, 2023 - addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Nov 21, 2023 cc @anonrig
The difference is not about assert. It's about URL changing the properties of the object. In Node.js 18 the symbol was enumerable and therefore it was compared by assert. But the URL object changed in the meanwhile.
I believe it is closely related to #46904 which changing the
symboltoprivate property.
assert.deepEqualonly compare the enumerable properties, so it no longer able to check thatsymbolproperty.Will it be acceptable to check like
Datein here, and create an dedicated checking forURLobject?
node/lib/internal/util/comparisons.js
Lines 184 to 204 in f425710
} else if (isDate(val1)) { if (!isDate(val2) || DatePrototypeGetTime(val1) !== DatePrototypeGetTime(val2)) { return false; } } else if (isRegExp(val1)) { if (!isRegExp(val2) || !areSimilarRegExps(val1, val2)) { return false; } } else if (isArrayBufferView(val1)) { if (TypedArrayPrototypeGetSymbolToStringTag(val1) !== TypedArrayPrototypeGetSymbolToStringTag(val2)) { return false; } if (!strict && (isFloat32Array(val1) || isFloat64Array(val1))) { if (!areSimilarFloatArrays(val1, val2)) { return false; } } else if (!areSimilarTypedArrays(val1, val2)) { return false; } Reacted by Xuguang Mei and SuperOleg39The
util.isDeepStrictEqual(val1, val2)method has the same problem (probably because it uses the same code).const util = require("node:util"); const url1 = new URL("http://foo1.com/"); const url2 = new URL("http://foo2.com/"); console.log(util.isDeepStrictEqual(url1, url2)); // true
FYI There's the same problem with
Promise. #55198 (comment)import assert from 'node:assert/strict'; const promise1 = Promise.resolve("foo"); const promise2 = Promise.resolve("bar"); assert.deepEqual(promise1, promise2);
- added a commit that references this issue
on Oct 13, 2024 - added a commit that references this issue
on Oct 15, 2024 - added a commit that references this issue
on Oct 19, 2024 - added a commit that references this issue
on Nov 27, 2024 - added a commit that references this issue
on Apr 15, 2025 - added 2 commits that reference this issue
on Mar 2, 2026
Version
v20.9.0
Platform
Linux regseblaptop 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
create file
index.js:node index.jsHow often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
The
index.jsscript must raise an error because the two URLs are different.What do you see instead?
No error.
Additional information
npx node@18 index.js