Version
v17.4.0
Platform
Darwin macbook-pro-5.lan 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 x86_64
Subsystem
assert
What steps will reproduce the bug?
assert.deepEqual(new Proxy(['foo'], {}), ['foo']); // works properly
assert.deepEqual(new Proxy(['foo'], { ownKeys: (target) => Reflect.ownKeys(target) }), ['foo']) // throws
assert.deepStrictEqual(new Proxy(['foo'], {}), ['foo']); // works properly
assert.deepStrictEqual(new Proxy(['foo'], { ownKeys: (target) => Reflect.ownKeys(target) }), ['foo']) // throws
In the above, Reflect.ownKeys(target) should be the same as not setting an ownKeys trap, but it isn't. The trap works fine elsewhere
Indeed,
Reflect.ownKeys(['foo']) // [ '0', 'length' ]
assert.deepEqual(new Proxy(['foo'], { ownKeys: (target) => ['0', 'length'] }), ['foo']) // throws
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior?
Using a ownKeys trap shouldn't cause comparison errors.
The ownKeys trap seems to be working fine elsewhere. I traced the code to:
|
const keys1 = getOwnNonIndexProperties(val1, filter); |
Where the
GetOwnNonIndexProperties function is called. Perhaps it is incorrectly filtering or the filtering is broken for proxies somehow?
What do you see instead?
Comparison errors from assert.deepEquals and assert.deepStrictEquals when the Arrays compared have the same content, but are using Proxies with ownKeys traps.
Additional information
I tried this on node 14, 16, and 17, with the same results.
Version
v17.4.0
Platform
Darwin macbook-pro-5.lan 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 x86_64
Subsystem
assert
What steps will reproduce the bug?
In the above,
Reflect.ownKeys(target)should be the same as not setting anownKeystrap, but it isn't. The trap works fine elsewhereIndeed,
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior?
Using a
ownKeystrap shouldn't cause comparison errors.The
ownKeystrap seems to be working fine elsewhere. I traced the code to:node/lib/internal/util/comparisons.js
Line 179 in dab8ab2
Where the
GetOwnNonIndexPropertiesfunction is called. Perhaps it is incorrectly filtering or the filtering is broken for proxies somehow?What do you see instead?
Comparison errors from
assert.deepEqualsandassert.deepStrictEqualswhen the Arrays compared have the same content, but are using Proxies withownKeystraps.Additional information
I tried this on node 14, 16, and 17, with the same results.