Meteor-Community-Packages / ground-db

GroundDB is a thin layer providing Meteor offline database and methods
https://atmospherejs.com/ground/db
MIT License
569 stars 76 forks source link

Don't use localstorage when size is higher than the limit #80

Open fermuch opened 9 years ago

fermuch commented 9 years ago

By accident I just sended 17000 records to a client. The JSON is 7800000 characters long. Without Ground DB Meteor manages to load this huge amount (I know it's crazy!), but when I mounted Ground DB the app suddenly freezed and I couldn't even close the tab.

By using https://arty.name/localstorage.html test, I discovered the limit on my browser (chrome 39.0.2171.65 (64-bit)) is at 5200000. If by any case someone gets over that limit, the browser just collapses and you can't do anything.

So, ground db should check the size limit of the browser and throw an error or switch back to Meteor's collections if the storage size is near the limit.

Another solution could be to implement Indexed DB or Sqlite for extreme cases where you need to store more than 5MB of data? (which seems to be the limit between browsers)

raix commented 9 years ago

Its on the todo to use an other storage type - at the moment theres no reliable available mem test - it varies depending on system and usage. Its a bit expensive to do a mem test at every app start, and really it should prop. be done regularly.

Any ways - I'm working on an intelligent subscription handler that will make sure to keep the most important data when quotas are hit.