electron: Inconsistent reporting of offline storage quota
Expected Behavior According to all documentation I can find, including Issue #4550, Electron should have 1/3 of free space available for offline storage. In addition, our apps should only be able to use 20% of that, per https://developer.chrome.com/apps/offline_storage#table.
Actual behavior I run the following code inside my Electron app:
const estimation = await navigator.storage.estimate();
console.log(`Quota: ${estimation.quota}`);
console.log(`Usage: ${estimation.usage}`);
and it reports that I actually have 100% of my free disk space available (i.e my 200GB drive has 105 GB free, and the code reports 105 GB available for use). I’ve tried this on multiple machines with 3 different Electron apps and it is consistent.
If it matters, I’m specifically interested in IndexedDb.
To Reproduce Run the above code inside any Electron app (either in the app or just in the console inside the renderer process). Compare the results to the actual free space on your drive.
Additional Information Primarily, I’m just looking for a clarification on whether what I’m seeing in the code is correct, that we have 100% of free disk space, or whether the documentation is correct and the code incorrect. Secondarily, I’d like to know if Electron will ever evict my data (specifically IndexedDb).
Thanks.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 17
- Comments: 21 (8 by maintainers)
Tested again in Electron 4.0.5 with the same results. Is there any official word?
Interested in the answer to this as well
It seems that the storage quota in Electron is unlimited: https://github.com/electron/electron/blob/master/shell/browser/special_storage_policy.cc#L20-L22
I think we can provide an API to let users set the storage quota themselves.
I’ve given up on IndexedDB simply because I couldn’t get an answer on this and couldn’t risk my product on it changing.
👋 Thanks for opening your first issue here! If you’re reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
@jacobq: agree, but it would be nice to see this officially documented somewhere. I can’t base my app on this assumption and then have data loss because something got evicted.
I did some testing myself and it appears that indexeddb quota is pretty high, if not unlimited as stated.
https://github.com/ccorcos/electron-indexeddb-quota
This behavior seems to be intended: https://bugs.chromium.org/p/chromium/issues/detail?id=897276
I’m looking into how Chromium calculates the storage quota, it seems that their algorithm is:
min(TotalDiskSpace * 0.8, FreeDiskSpace), so for most people all free disk space would be returned.I have also tested with Chrome 79 and it returned all free disk space as storage quota.
@elrDevelopment I believe that’s only for
localStorageandsessionStorage(and in current electron 9 nightlies the limit for those is 100MiB), notIndexedDB. So far I have not seen it officially documented, but I believe there is no limit for storage inIndexedDB