pfooti
pfooti

Reputation: 2704

Can indexedDB run out of space?

I'm using localforage with the indexedDB driver. My indexedDB store is rather large, but I was under the impression that indexedDB never really runs out of space, it just expires old content.

However, a large number of requests to the indexedDB are failing with the error: 'DOMException: Transaction timed out due to inactivity.', after hanging for 60 seconds.

If I just do a simple

function testWrite(n) {
  localforage.setItem(`test:${n}`, Math.random().toString(16).slice(2))
  .then((v) => console.log(x))
  .catch((err)=>console.log(err))
}
for (var x = 0; x < 10; x++) {
  testWrite(x)
}

in an incognito window pointed at my webapp, it works fine. If I do the same in the non-incognito window, I get the timeout. The important thing is: I get the same timeout problems if I increase the loop size to something big, even in a fresh session. So it feels like there's some threshold somewhere that's not quite right.

Upvotes: 2

Views: 5679

Answers (2)

vixalien
vixalien

Reputation: 390

According to: https://www.html5rocks.com/en/tutorials/offline/quota-research/, It varies.

On Mobile, in Firefox, the limit is 5MBs, however, the user can allow unlimited storage use, while in Chrome, it can store data up to the speified Quota (which can be tuned in Settings).

On Desktop, Firefox has a limit of 50MBs unless of course the user allow unlimited storage. In Chrome, it still respects the Quota, which can be tuned in DevTools > Application > Storage.

(By Chrome I mean Webkit, hence Safari, Opera and Mobile WebViews should also work.)

Upvotes: 1

CY_
CY_

Reputation: 7628

There isn't any limit on a single database item's size, however there is in some cases a limit on each IndexedDB database's total size. This limit (and the way the user interface will assert it) varies from one browser to another: https://www.raymondcamden.com/2015/04/17/indexeddb-and-limits/

Upvotes: 6

Related Questions