After further investigation I found that this same problem was occurring whenever I tried to save changes to an object that had loaded a related collection (i.e. the contents of a navigation property), where the objects in the collection then had a reference back to the parent. I tracked the error down to the following line in breeze.debug.js (version 1.3.5):
var bundle = JSON.stringify(saveBundle);
I found that if I replaced this line with the following (as per JSON.stringify, avoid TypeError: Converting circular structure to JSON) then the error no longer occurred:
var cache = [];
var bundle = JSON.stringify(saveBundle, function (key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
cache.push(value);
}
return value;
});
cache = null; // Enable garbage collection
While this fixes my current issue I feel that there must be an alternative approach to this - surely I cannot be the only one trying to save changes in this scenario.