Unspecified ownKeys result for duplicate keys in V8 Proxy
0 reputation · 08 Oct 2020, 12:04 UTC
The ECMAScript specification defines the Proxy ownKeys trap as returning an array of property keys, with the behavior for duplicate entries left unspecified. V8 implements Proxy traps for JavaScript engines used in Chrome and Node.js, and the handling of duplicate keys in the ownKeys result is a documented area of implementation flexibility.
The goal is to clarify the contract V8 provides for enumeration and reflection when a trap returns duplicate keys. The constraint is that the specification explicitly permits engines to collapse, reorder, or reject such results, which creates uncertainty about cross-release consistency for code that relies on Reflect.ownKeys and property enumeration semantics.
Is the deduplication of duplicate keys returned by ownKeys a stable characteristic of current V8 releases, or is it implementation-defined and subject to change? How does this unspecified handling affect the consistency of Reflect.ownKeys and enumeration order across V8 versions? Is there a documented stability guarantee for the set of keys exposed by a Proxy when the trap returns duplicates?