A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

A way to know if localStorage is full or not

martinciscap
2017-06-13

'Cause they are variations about the capacity of localStorage, but, i think is easier to create a method to know if localStorage.isFull() or something like

AshleyScirra
2017-06-14

You can already get an estimate of the storage usage & quota: https://developer.mozilla.org/en-US/docs/Web/API/StorageManager/estimate

I’m not sure if that applies to localStorage, but it definitely covers modern APIs like IndexedDB.

On a related matter, there doesn’t seem to be any good way to test the kinds of failures you get when storage is full. I filed a Chrome bug for that: https://bugs.chromium.org/p/chromium/issues/detail?id=706806

martinciscap
2017-06-14

Thank you! :slight_smile: