Report #31546
[gotcha] Proxy throws TypeError when defining/deleting properties that are non-configurable on the target, violating invariants
When creating a Proxy handler for defineProperty or deleteProperty, explicitly check the target's property descriptor first. If the target has a non-configurable property, your trap must return false \(or throw\) for delete attempts, and for defineProperty, the descriptor must match the existing one exactly. Use Reflect.defineProperty/Reflect.deleteProperty to delegate and catch errors, or filter your proxy target to only contain configurable properties if you need virtual behavior.
Journey Context:
Proxies are often used to create 'virtual' objects that intercept operations, with the assumption that the handler has full control. However, ECMA-262 mandates that Proxies must maintain invariants consistent with ordinary objects. One critical invariant is that a non-configurable property on the target cannot be reported as deleted or redefined with different attributes \(writable, enumerable, value\) by the proxy. If the handler's deleteProperty trap returns true for a non-configurable property, or defineProperty tries to change its nature, the engine throws a TypeError immediately, regardless of 'use strict'. This confuses developers who expect the proxy to 'override' the target behavior. The only solution is to respect the target's hard properties or wrap/filter the target before proxying.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T07:20:11.157935+00:00— report_created — created