question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ember.A seems to modify array instance

See original GitHub issue

We’re seeing a bug in the Ember Simple Auth dummy app (simplabs/ember-simple-auth#1260) that seems to be caused by the fact that ~Enumerable.uniq~Ember.A tries to modify the provided array. This only seems to affect addon projects where prototype extension is disabled (this is mostly an assumption for now though).

Reproduction steps:

var array = ['a', 'a'];
Object.freeze(array);
Ember.A(array);

// =>
ember.debug.js:21542 Uncaught TypeError: Cannot add property nextObject, object is not extensible
    at Object.defineProperty (ember.debug.js:21542)
    at applyMixin (ember.debug.js:20576)
    at MixinPrototype.apply (ember.debug.js:20770)
    at Object.A (ember.debug.js:37397)
    at eval (eval at init (query-string.js:35), <anonymous>:1:7)
    at Class.init (query-string.js:35)
    at new Class (ember.debug.js:36118)
    at Function._ClassMixinProps.create (ember.debug.js:36306)
    at Class.buildQueryString (oauth2-code.js:110)
    at Class.buildUrl (oauth2-code.js:120)

This only seems to fail in addon dummy apps but not in real apps.

/cc @Turbo87

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
stefanpennercommented, Mar 17, 2017

Ya. It’s already mega costly. Copying would also likely break some code that expects the array to be The same.

Work should be done so that Ember.A can be phased out

0reactions
marcoowcommented, Mar 17, 2017

I guess the fix for actually making it so that the object wasn’t modified at all would be to always clone the object before applying the mixin (if prototype extensions are disabled/the mixin hasn’t already been applied on the prototype) but I guess the performance overhead for that is prohibitive?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ember.js - How do I modify elements in an array that is ...
I make a copy of the array, modify it, and then set it back. But somehow Ember complains about the 4th line, where...
Read more >
Ember.Array - 2.14
This mixin implements Observer-friendly Array-like behavior. It is not a concrete implementation, but it can be used up by other classes that want...
Read more >
How to Avoid Shared States Between Mixins in Ember.js
As you can see, it looks like they are sharing the same array instance between them, which leads to buggy behavior. This bug...
Read more >
Converting Your Ember App to TypeScript - Inside Skylight
PromiseArray makes sense, but I wouldn't expect an array of any values. It should be a more specific type. Something seems wrong here....
Read more >
The 8 Most Common Mistakes That Ember.js Developers Make
In this example your component then can be re-used, by just changing the "setaction" to point to a different action for the data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found