Temporary Fix for ember-data bug

I have run into an ember-data bug that is not solved by ember-data 2.11.0 yet. If you see strange extra records in ember-data that sometimes disappear after a browser refresh you can set coalesceFindRequests: false to temporary solve this bug like this :

https://github.com/broerse/ember-cli-blog/blob/master/app/adapters/application.js#L9

1 Like

I have an issue where let’s say I have 5 people on a people/people-list route - and I click person #4, people/:id - land on the single template… refresh browser (single template is correct)… navigate back to people/people-list and then person #4 is 1st in the list instead of 4th. Long shot, but do you think this is related to that bug?

I don’t think that’s a bug; it’s the expected behavior.

When you start on /people/4, Ember loads just that record into the store. When you navigate to /people/people-list then it loads all the people and adds them to the store. So they will be added after #4.

What you want to do is to have your people-list template show a sorted list of users. You can use the sortBy computed helper to create a computed property that is a sorted copy of the people list, and use the sorted list in the {{#each}} helper in your template.

I’ve never noticed that behaviour - but this is a very simple unsorted numbered list example - so it was suddenly very obvious! Glad to hear I’m not crazy! :slight_smile: Thank you very much for weighing in.

It is a bug because I don’t think the behavior should change if you want to coalesce requests.

When you have two or more belongsTo items with no record on the hasMany side and set coalesceFindRequests: true ember-data asks the backend for the records in as it should do but fails to destroy the records that are not on the backend. They magically appear on the hasMany side. See GitHub - jlami/ember-bug-empty-data

When you have two or more belongsTo items with no record on the hasMany side and set coalesceFindRequests: false ember-data asks the backend for the records as it should and destroys the records that are not on the backend. This is how destroy should work for coalesceFindRequests: true also.