kurko / ember-indexeddb-adapter

Ember Data IndexedDB Adapter
MIT License
43 stars 16 forks source link

Assertion Failure when deleting record with hasMany relationship #21

Closed dpfens closed 6 years ago

dpfens commented 10 years ago

I am working with a few models with hasMany relationships on them and was getting the following errors when calling deleteRecord() followed by save on them:

Error: Assertion Failed: calling set on destroyed object at new Error (native) at Error.EmberError (file:///home/doug/workspace/project/js/ember-1.7.0.js:13538:23) at Object.Ember.assert (file:///home/doug/workspace/project/js/ember-1.7.0.js:3722:15) at set (file:///home/doug/workspace/project/js/ember-1.7.0.js:16834:13) at Ember.Object.extend.hasManyDidChange (file:///home/doug/workspace/project/js/ember-data-beta7.prod.js:5939:11) at null. (file:///home/doug/workspace/project/js/ember-data-beta7.prod.js:5928:18) at file:///home/doug/workspace/project/js/ember-1.7.0.js:14897:20 at Object.OrderedSet.forEach (file:///home/doug/workspace/project/js/ember-1.7.0.js:14739:14) at Object.Map.forEach (file:///home/doug/workspace/project/js/ember-1.7.0.js:14895:14) at Ember.Object.extend.reloadHasManys (file:///home/doug/workspace/projectl/js/ember-data-beta7.prod.js:5925:23)

followed by:

Uncaught Error: Assertion Failed: Error: Assertion Failed: calling set on destroyed object ember-1.7.0.js:3722 Ember.assert ember-1.7.0.js:3722 RSVP.onerrorDefault ember-1.7.0.js:27916 exports.default.trigger ember-1.7.0.js:46478 Promise._onerror ember-1.7.0.js:47477 publishRejection ember-1.7.0.js:45740 (anonymous function) ember-1.7.0.js:29069 DeferredActionQueues.invoke ember-1.7.0.js:634 DeferredActionQueues.flush ember-1.7.0.js:684 Backburner.end ember-1.7.0.js:147 Backburner.run ember-1.7.0.js:202 apply ember-1.7.0.js:18380 run ember-1.7.0.js:16999 operation.onsuccess ember-indexeddb_adapter.js:894

I learned through this EmberJS discussion post how to fix it from another user's post:

My custom data adapter's delete function was returning a json object. As soon I set it to return an empty string the issue went away.

I added return ''; on operation.onsuccess which allows the records to be deleted, but still get the errors so its not a perfect fix. I will update this if I resolve it.