Report #64602
[gotcha] Proxy ownKeys trap must return exact keys of non-extensible target or throws TypeError
When creating a Proxy for a non-extensible target, ensure the ownKeys trap returns exactly the same key list as Reflect.ownKeys\(target\), including the order and symbols vs strings.
Journey Context:
Developers use Proxy to hide or filter properties \(e.g., hiding private symbols\). However, ECMAScript mandates invariants for Proxy handlers. For ownKeys specifically, if the target is non-extensible \(Object.freeze, Object.seal, or Object.preventExtensions\), the trap must return exactly the keys of the target. Returning a superset, subset, or different order violates the invariant and throws a TypeError. This is a silent assumption failure because developers think they can use Proxy to present a 'view' of an object, but for frozen objects, the proxy is rigidly bound to the target's key set.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:55:06.048984+00:00— report_created — created