Assertion Failed: You modified xy twice


#1

Hey,

I am new to ember.

I want to display async relations of a model but I am running into the You modified "model.posts" twice on <eui@model:user::ember271:vV63NgcG0b4R7pm0th0K> in a single render. error.

I am using the newly generated ember app with these modifications (I omitted the imports):

models/post.js

export default DS.Model.extend({
      message: DS.attr('string')
});

models/user.js

export default DS.Model.extend({
  name: DS.attr('string'),
  posts: DS.hasMany('post', { async: true })
});

routes/user.js

export default Ember.Route.extend({
  model(params) {
    return this.store.findRecord('user', params._id);
  }
});

routes/users.js

export default Ember.Route.extend({
  model() {
    return this.store.findAll('user');
  }
});

templates/user.js

{{#each model.posts as |post|}}
  {{post.message}}
{{/each}}

What am I doing wrong?

Thank you! Daniel


#2

Daniel,

Do you happen to be using Ember Data version 2.14.2? If so there seems to be a bug that is causing this, https://github.com/emberjs/data/issues/4942

I’ve rolled back to 2.13.2 and everything is happy again.

Let me know if rolling back works… if not we have some digging todo :slight_smile:

Cheers, Benjamin


#3

Hey Benjamin,

thank you very much! After rolling back to 2.13.2 it works es expected!

Since I am new to ember (but not to web development) I could not believe that this is impossible. I researched the web for like 2 days straight.

Again, many thanks!

Daniel


#4

It’s super rare that this happens, most of the time the thing to do is upgrade :grin:


#5

Year, well… shit happens :slight_smile:

Funny thing is, in 15 years I never head to post in a forum for something like this. But I really couldn’t wrap my head around this one. And in 15 years I never run into a bug :smiley: I guess there really is a first for everything.