I want to make sure my code handles the QuotaExceededError
with IndexedDB properly, I'd prefer not torturing my SSD to do so.
Is there any way to set a storage limit (like to say 5 MB) in the developer tools or browser settings?
I want to make sure my code handles the QuotaExceededError
with IndexedDB properly, I'd prefer not torturing my SSD to do so.
Is there any way to set a storage limit (like to say 5 MB) in the developer tools or browser settings?
Share Improve this question asked Oct 28, 2018 at 1:42 jdwjdw 1,5733 gold badges19 silver badges26 bronze badges 1- Chrome is working on it Issue 945786 – Binyamin Commented Oct 12, 2019 at 17:19
5 Answers
Reset to default 12In Chrome, you can launch the browser with --user-data-dir pointing at a smaller volume, e.g. via tmpfs
.
Chrome doesn't have devtools support for such testing, but it's on the wish list.
As of today you can open DevTools, go to the Application Panel and check the Simulate custom storage quota
label and then provide the maximum amount of MB that can be stored by IndexedDB.
Chrome DevTools Application Panel Screeshot
I've used a VM with a small hard drive. That's not ideal obviously, so I hope someone suggests a better answer!
Building on @joshua-bell's answer but adding detail on exactly how to do this in Mac OSX:
- Copy the
mount-ram.sh
file at https://gist.github.com/koshigoe/822455 (you will probably want the unmount-ram.sh file for later as well) - Save that file anywhere you want
- From the directory where you saved
mount-ram.sh
, runsh mount-ram.sh mytmpfs 512
cd /Applications/Google Chrome.app/Contents/MacOS
(at least that's where it was on my machine)./Google\ Chrome --user-data-dir=/PATH/TO/mytmpfs/
, replacing/PATH/TO/mytmpfs/
with the path the directory you created in step 3.
Now you've got Chrome running, pointed at a file system with only 512MB of storage.
If you're ok with a 100MB storage limit, just open Chrome in incognito mode.
To see how much storage you have left, try this:
navigator.storage.estimate().then(console.log)