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

You attempted to access the __DESCRIPTOR__ property (of <frontend@service:prototypes::ember581>) #16263

Closed
sly7-7 opened this issue Feb 20, 2018 · 7 comments

Comments

@sly7-7
Copy link
Contributor

sly7-7 commented Feb 20, 2018

Related to #16148

I have a service, injected in a route (extending the AuthenticatedRouteMixin). When I do this.get('prototypes'),so, in my use case I don't know if the error is coming from:

  • The route accessing a service
  • The route itself
  • The service itself

Let me now if you need more information.
For now, I will try to revert 2.18 (ember 3.0.X seems to have problems with ie 11)

There is more information at https://github.com/emberjs/ember.js/issues/16148, and
you can help us improve this error message by telling us more about what happened in
this situation.
    at new EmberError (error.js:40)
    at assert (index.js:139)
    at Object.get (core_object.js:57)
    at isDescriptorTrap (ember-metal.js:3258)
    at get (ember-metal.js:3430)
    at Class.get (observable.js:38)
    at route.js:62

cc/ @wycats
Maybe this is an issue in ember-simple-auth, so kindly cc/ to @marcoow

@btecu
Copy link
Contributor

btecu commented Feb 20, 2018

Do you have any unknownProperty or setUnknownProperty?

@sly7-7
Copy link
Contributor Author

sly7-7 commented Feb 20, 2018

In my service, yes, I have an unknownProperty function. Actually I had merely copy-paste the code from https://github.com/kategengler/ember-feature-flags/blob/master/addon/services/features.js which also have an unknowProperty function

@wycats
Copy link
Member

wycats commented Feb 20, 2018

@sly7-7 can you paste the whole error message, including the details about which properties are involved?

@sly7-7
Copy link
Contributor Author

sly7-7 commented Feb 21, 2018

ember-console.js:29 Error while processing route: widget-group.index Assertion Failed: You attempted to access the `__DESCRIPTOR__` property (of <frontend@service:prototypes::ember579>).
Since Ember 3.1, this is usually fine as you no longer need to use `.get()`
to access computed properties. However, in this case, the object in question
is a special kind of Ember object (a proxy). Therefore, it is still necessary
to use `.get('__DESCRIPTOR__')` in this case.

If you encountered this error because of third-party code that you don't control,
there is more information at https://github.com/emberjs/ember.js/issues/16148, and
you can help us improve this error message by telling us more about what happened in
this situation. Error: Assertion Failed: You attempted to access the `__DESCRIPTOR__` property (of <frontend@service:prototypes::ember579>).
Since Ember 3.1, this is usually fine as you no longer need to use `.get()`
to access computed properties. However, in this case, the object in question
is a special kind of Ember object (a proxy). Therefore, it is still necessary
to use `.get('__DESCRIPTOR__')` in this case.

If you encountered this error because of third-party code that you don't control,
there is more information at https://github.com/emberjs/ember.js/issues/16148, and
you can help us improve this error message by telling us more about what happened in
this situation.
    at new EmberError (http://localhost:4200/assets/vendor.js:25254:25)
    at assert (http://localhost:4200/assets/vendor.js:25497:15)
    at Object.get (http://localhost:4200/assets/vendor.js:50711:73)
    at isDescriptorTrap (http://localhost:4200/assets/vendor.js:37443:87)
    at get (http://localhost:4200/assets/vendor.js:37615:41)
    at Class.get (http://localhost:4200/assets/vendor.js:49512:34)
    at http://localhost:4200/assets/frontend.js:10830:18
    at tryCatcher (http://localhost:4200/assets/vendor.js:62499:21)
    at invokeCallback (http://localhost:4200/assets/vendor.js:62671:33)
    at publish (http://localhost:4200/assets/vendor.js:62657:9)

Concerning the involved properties It's hard to say. The error is thrown when I access the prototypes service from the afterModel hook of a route. Just this.get('prototypes') make the app crash.
Here is the code of the service if it helps (BTW Thanks to @kategengler for her addon).

import { camelize } from '@ember/string';
import { keys } from '@ember/polyfills';
import EmberObject from '@ember/object';
import Service from '@ember/service';

export default Service.extend({
  flags: EmberObject.create(),

  setup(flags) {
    var normalizedFlags = {};
    for (var flag in flags) {
      if (flags.hasOwnProperty(flag)) {
        normalizedFlags[this._normalizeFlag(flag)] = flags[flag];
      }
    }
    this.set('flags', EmberObject.create(normalizedFlags));
  },

  showAll() {
    return this.get('flags').getProperties(keys(this.get('flags')));
  },

  enable(flag) {
    var normalizedFlag = this._normalizeFlag(flag);
    this.get('flags').set(normalizedFlag, true);
    this.notifyPropertyChange(normalizedFlag);
  },

  enableAll() {
    keys(this.get('flags')).forEach(function(flag) {
      this.enable(flag);
    }, this);
  },

  disable(flag) {
    var normalizedFlag = this._normalizeFlag(flag);
    this.get('flags').set(normalizedFlag, false);
    this.notifyPropertyChange(normalizedFlag);
  },

  disableAll() {
    keys(this.get('flags')).forEach(function(flag) {
      this.disable(flag);
    }, this);
  },

  unknownProperty(key) {
    return this.enabled(key);
  },

  enabled(flag) {
    var normalizedFlag = this._normalizeFlag(flag);
    return !!this.get('flags').get(normalizedFlag);
  },

  _normalizeFlag(flag) {
    return camelize(flag);
  }
});

@rwjblue
Copy link
Member

rwjblue commented Feb 23, 2018

In this case, the proxy's unknownProperty always returns a value (either true or false AFAICT). This will always trigger the proxy assertion when accessing properties that are not properties of the proxy itself.

@rwjblue
Copy link
Member

rwjblue commented Feb 23, 2018

Submitted a fix in #16274

@sly7-7
Copy link
Contributor Author

sly7-7 commented Feb 24, 2018

Thanks a lot @rwjblue ❤️

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

No branches or pull requests

4 participants