Persistent removals do not work for heavy collections
I've just written test program that adds big items (about 5Mb each) to the collection until QuotaExceededError is issued. On my desktop (Chrome 36, Win7) the collection total size grows until about 50 Mb (10 items stored). So far so good. But when I'm trying to remove the items, I again receive QuotaExceededError. I do removal like this:
coll.remove({
'_id': {
'$eq': key
}
},
function(result) {
if(result && !result.length) {
alert('Cannot remove item');
return;
}
coll.save(function(err) {
if(err && err.name && err.message)
alert(err.name +': ' + err.message);
});
});
coll.remove() succeeds but coll.save() fails issuing QuotaExceededError. I did not check if it works if removing all items without coll.save() until the collection is empty, and then call final coll.save(). But I need "persistent" removals scenario when save() is called after each removal. Is it a bug?
P.S. The QuotaExceededError is also issued while removing even if the collection is heavy but doesn't consume all space quota, say of only 8 items (40Mb). For lighter collections, say of only 4-5 items, the removal is successful.
I'm using 1.4.4 production.
Hi ya,
Thanks for the issue report.
I wonder if the item is actually being removed at all. The query you use with $eq should just be:
coll.remove({
_id: key
}, function () {
// Rest of logic
});
Does it work if you do it this way?
P.S. It should also work via the $eq operator but I'll need to test this via a unit test. It might actually be a bug with $eq when removing.
OK confirmed that $eq does work with .remove() so I'm now wondering if the QuotaExceededError is a bug somewhere in LocalForage... since all we are doing is asking LocalForage to set data against a key. It's not appending it.