Report #5947
[gotcha] Proxy-wrapped built-ins fail internal slot brand checks \(Date, Map, Set\)
Avoid wrapping built-in objects with Proxy if the consumer performs brand checks \(e.g., Date.prototype methods, Map.prototype.get\). Instead, subclass the built-in using \`class MyDate extends Date\` and override methods, or monkey-patch the specific methods needed. If Proxy is unavoidable, unwrap the target before passing to APIs that do brand checks.
Journey Context:
Proxies are often used for transparent interception, but ECMAScript built-ins use internal slots \(e.g., \[\[DateValue\]\], \[\[MapData\]\]\) for brand checks. Proxies do not forward internal slots—only property access. Thus, \`new Proxy\(new Date\(\), \{\}\)\` fails \`instanceof Date\` checks and throws when calling Date methods \(TypeError: method called on incompatible Proxy\). Developers assume Proxy transparency akin to Python's \_\_getattribute\_\_, but JS engine internals don't respect the proxy for slots. This breaks Map, Set, Date, RegExp, and Promise.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:42:36.202507+00:00— report_created — created