Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove property descriptor assertion from args proxy #1306

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sandydoo
Copy link

This PR fixes emberjs/ember.js#19130.

The point of the assertion was to deter people from trying to define stuff on the args. The intention hasn’t changed — don’t do that! But it turns out that upholding that assertion is not as straightforward. JavaScript can, in certain cases, trigger the assertion internally.

How? The answer is Proxies. Despite having the ability to completely override internal methods, Proxies still have to abide by certain rules (the spec calls them “invariants”). Did you try to mark a property as non-configurable, even though it’s configurable on the target? That’s not supported! And the browser is required to check for this. That’s how calling get can turn into an additional, and perhaps unexpected, call to getOwnPropertyDescriptor.

In our case, the assertion was incorrectly triggered when trying to get an undefined property on a proxy whose target is an args proxy. That made it impossible to wrap args in a Proxy — a use-case that was deemed reasonable enough to support.

The point of the assertion was to deter people from trying to define
stuff on the args. The intention hasn’t changed — don’t do that! But
it turns out that upholding that assertion is not as straightforward.
JavaScript can, in certain cases, trigger the assertion internally.

How? The answer is Proxies. Despite having the ability to completely
override internal methods, Proxies still have to abide by certain
rules (the spec calls them “invariants”). Did you try to mark a
property as non-configurable, even though it’s configurable on the
target? That’s not supported! And the browser is required to check for
this. That’s how calling `get` can turn into an additional, and perhaps
unexpected, call to `getOwnPropertyDescriptor`.

In our case, the assertion was incorrectly triggered when trying to
`get` an undefined property on a proxy whose target is an args proxy.
That made it impossible to wrap args in a Proxy — a use-case that was
deemed reasonable enough to support.
@NullVoxPopuli
Copy link
Contributor

@chancancode thoughts? less complex code seems like improvement 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Wrapping args in a Proxy throws an unintended assertion
2 participants