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

unloadAll does not clear internalModel Record ID map #5041

Closed
cah-brian-gantzler opened this issue Jun 27, 2017 · 8 comments
Closed

unloadAll does not clear internalModel Record ID map #5041

cah-brian-gantzler opened this issue Jun 27, 2017 · 8 comments

Comments

@cah-brian-gantzler
Copy link

Using Ember Data 2.13.1

The backend API I am using required me to specify the id of records, so when a createRecord is given, the id is provided. If a createRecord is added to the store and persisted, then unloadAll is performed on the model, when another record is attempted to be created with the same id, an assert is throwing that the id is already in use. There are no records in the store with that id. It appears that the unloadAll is not clearing an internal record map.

screen shot 2017-06-27 at 1 19 40 pm

The assert is in the buildInternalModel method of store. As you can see the id is still recorded in the _idToModel and idToRecord yet the _models array is empty. This is preventing me from adding the same item to another shopping cart after the first cart has been unloaded

@tylerturdenpants
Copy link
Member

The workaround at travis-ci/travis-web#1173 might be of some help until the issue is addressed.

@cah-brian-gantzler
Copy link
Author

Thanks, that does appear what needs to be done. I am doing an unloadAll, can adapt the code. Hoping that makes it into Ember-data proper sometime.

@acorncom
Copy link
Contributor

Related issue: #4972

@lolmaus
Copy link
Contributor

lolmaus commented Oct 3, 2017

@tylerturdenpants Thank you. 🙇 This fix worked for us.

I must add that a simple record.unloadRecord() fails for us (Ember Data 2.15.3). ED seems to enter an inconsistent state. The actual error is cannot call eachAttribute on null somewhere deep in ED internals.

A workaround I found is to destroy the record before unloading it:

record
  .destroyRecord()
  .then(() => {
    record.unloadRecord()
    // the Travis fix goes here
  })

@lolmaus
Copy link
Contributor

lolmaus commented Oct 3, 2017

This is the specific problem I'm talking about: #4963

@tylerturdenpants
Copy link
Member

@lolmaus you are welcome. It's been a huge challenge to move from 2.12 because my app, which loads and unloads very frequently (I deal with quasi real time pricing). The is the first time in 2 years I've been this far behind in a single core package of Ember.

It deeply saddens me that the plethora of unload issues still exist across 3 published versions of Ember, namely 2.13, 2.14, and 2.15. While I can't contribute to the solution by submitting PR's, I can provide some financial incentives out of my own pocket. Hopefully this issue will get a core champion soon.

Since there are so any of us affected by these issues, maybe we could come together to offer core members something? to pause on features scheduled for 2.16 and finally put an end to this ongoing unload nightmare.

I hope this reply is taken in the right way. I love Ember. I lover Ember data. But I simply cannot give back. The Ember data internals are way above my skill set. I understand the value of open source and the core members who give their free time.

@ghost
Copy link

ghost commented Dec 12, 2017

Commented on the other issue, but it bears linking here: #4972 (comment)

@runspired
Copy link
Contributor

I believe this was resolved as of #5378, if not please reopen

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

5 participants