How to test IndexedDB 'QuotaExceededError' without filling disk?
Asked Answered
B

5

7

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?

Behnken answered 28/10, 2018 at 1:42 Comment(1)
Chrome is working on it Issue 945786Sesquiplane
K
12

In 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.

Kami answered 29/10, 2018 at 20:0 Comment(1)
Good answer. Expanding on this you can check the storage limits for the error being thrown here: chromium.googlesource.com/chromium/src/+/refs/heads/master/… and use sudo mount -t tmpfs -o size=1G tmpfs /mnt/mytmpfs for the specific limit you want to test.Alcantar
P
7

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

Paving answered 3/11, 2021 at 15:38 Comment(0)
K
1

I've used a VM with a small hard drive. That's not ideal obviously, so I hope someone suggests a better answer!

Kesterson answered 28/10, 2018 at 19:14 Comment(0)
G
1

Building on @joshua-bell's answer but adding detail on exactly how to do this in Mac OSX:

  1. 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)
  2. Save that file anywhere you want
  3. From the directory where you saved mount-ram.sh, run sh mount-ram.sh mytmpfs 512
  4. cd /Applications/Google Chrome.app/Contents/MacOS (at least that's where it was on my machine)
  5. ./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.

Gilliangilliard answered 20/11, 2019 at 21:1 Comment(0)
L
0

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)
Lightfoot answered 8/6, 2020 at 21:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.