-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Bug] Wrapping args in a Proxy throws an unintended assertion #19130
Comments
Hi @sandydoo, could you mention real-life use case where you have to wrap args into proxy? |
I'm trying to migrate ember-google-maps to Octane. I was hoping I could avoid converting |
It seems nobody else has run into this problem, so I’m going to close this issue as “likely too esoteric and niche” 😆. For anyone reading this, here’s the TL;DR: don’t wrap |
Hi @sandydoo, may it help you? glimmerjs/glimmer-vm#1304 |
So, the reason we put that assertion there at all was just to discourage people from attempting strange things like dynamically defining properties on What's odd to me is that you're triggering In either case, I think we could relax this restriction. |
The thing is, you can replicate the behaviour like so: let firstProxy = new Proxy(Object.create(null), {
get() {
console.log('checking the first proxy');
return;
},
getOwnPropertyDescriptor() {
console.log('I should not be called');
return;
},
});
let secondProxy = new Proxy(firstProxy, {
get() {
return Reflect.get(...arguments);
},
});
secondProxy.undefinedProp; Safari, Firefox...they both end up calling The repro I made is essentially the same. If you run through the debugger step-by-step, you’ll notice how we suddenly jump to
🤷 Could be fun to see what happens if you then give it some value in SpoilerNothing fun happens. It just returns `undefined`. But, it does complain if you do something funny like set `configurable: false`, so it is actually checking what you return from `getOwnPropertyDescriptor`. Weird.
Ah, that makes sense.
@lifeart, thanks for keeping an eye out ❤️ |
Huh, really interesting... it must be something that the proxy is doing for some reason. I'll have to read the spec on that at some point. I think we can remove that assertion for now though, and instead just return a blank/default property descriptor if the property doesn't exist. |
Alright, alright, you got me curious 🤣 Now I have to look! Here’s the relevant bit:
And here’s what Proxy actually does in the
And here are those “invariants”: https://262.ecma-international.org/11.0/#sec-invariants-of-the-essential-internal-methods
Well, I guess you pay a price for that flexibility 🤷 Now I’m curious what could happen if Proxy could break these “essential integrity invariants”... What a rabbit hole 🙄 |
i also had this issue. simple workaround if possible: dont set args as the proxy target.
|
🐞 Describe the Bug
If you wrap the
args
proxy in another proxy and try to get an undefined property, Ember throws an assertion.🔬 Minimal Reproduction
The repro app will display errors in the console.
https://github.com/sandydoo/ember-repro-args-proxy
😕 Actual Behavior
It seems that, as part of its implementation,
Proxy
callsgetOwnPropertyDescriptor
on the target object. I don't have control over this 🤷♂️. In the case ofargs
,getOwnPropertyDescriptor
throws an error if you try to call it for an undefined prop. The purpose of the assertion seems to be to deter people from usinggetOwnPropertyDescriptor
altogether, but since it's necessary for enumeration, it can only throw an error for undefined props.ember.js/packages/@ember/-internals/glimmer/lib/component-managers/custom.ts
Lines 220 to 224 in e6c38ec
🤔 Expected Behavior
I should be able to transparently access properties on
this.args
even via a Proxy.🌍 Environment
🧠 Thoughts
The assertion strikes me as a bit problematic for a few reasons:
Proxy
.getOwnPropertyDescriptor
for any defined prop without issues. I'm not sure of what use that would be though...I would appreciate some feedback on this issue. Are proxies a no-go with args or can we live with the possibility of people calling
getOwnPropertyDescriptor
?The text was updated successfully, but these errors were encountered: