-
Notifications
You must be signed in to change notification settings - Fork 44
Description
After getting some errors "Queued save failed: Converting circular structure to JSON" when saving in Breeze I tracked the issue down to the function rememberAddedOriginalValues in breeze.savequeuing.js
My theory is that the circular structure issue happens because the list of Added entities sometimes ends up containing Modified (and other?) entities.
On line ~189 after:
var added = entities ? entities.filter(function (e) { return e.entityAspect.entityState.isAdded(); }) : entities.filter(function (e) { return e.entityAspect.entityState.isAdded(); }) : self.entityManager.getChanges(null, breeze.EntityState.Added);
It looks like the array in added should contain only Added entities, however for some reason it sometimes contains other entries.
To remove these other entities I added this immediately after the previous lines to remove entities with entitystates other than Added:
for(var x = 0; x < added.length; x++) { if(added[x].entityAspect && added[x].entityAspect.entityState.name != breeze.EntityState.Added) { added.splice(x, 1); x--; } }
This at least seems to have sorted my issues.