3 ms·
> Multiple tabs of an app using IndexedDB will invariably write to the same IndexedDb database. Without cross-tab locking, database corruption is hard to avoid.
by moogly 5y ago
> Multiple tabs of an app using IndexedDB will invariably write to the same IndexedDb database. Without cross-tab locking, database corruption is hard to avoid.
I solved this a few years ago by generating a uuid in SessionStorage and using that as a composite key for tab isolation. Worked very well. That solution is still in production. The IndexedDB wrapper I used was Dexie. Not great for long-lived data, naturally, but we needed IndexedDB for speed, storage size and an async API.
I later used localForage and I found that to be extremely limiting in comparison (because of LocalStorage being the lowest common denominator). I would not recommend localForage for IndexedDB unless you do really, really, really simple stuff.