jakearchibald / idb-keyval

A super-simple-small promise-based keyval store implemented with IndexedDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Error recovery for default store eg when `Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.` occurs

TedChenNZ opened this issue · comments

Feature Request - Error recovery for default store

Currently if we run into an error using the default store, there is no way to recover without refreshing the page.

This is due to the cache of defaultGetStoreFunc which means we keep the same connection for the default store, and we have no method of resetting it.

The error and reproduction steps (sort of)

The error that I'm seeing in production is Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing..
I believe this mainly happens when a user has a connection open, sleeps the computer, then wakes it later. However I have trouble reproducing it in that manner. Others seem to have this issue too eg https://bugs.chromium.org/p/chromium/issues/detail?id=1085724

The one way I can reproduce this error 100% of the time is to manually delete the indexed-db database (though I don't think that's what users are actually doing just due to the sheer amount of times that we're experiencing the 'failed to execute transaction' error according to the Sentry logs). Attached is a gif and a sandbox of how I reproduce this error

no error recovery

https://codesandbox.io/s/competent-star-8gkf4c?file=/src/App.js

Workaround

My current workaround is use a customStore rather than the default store, and creating a new custom store if the error occurs.

eg
workaround

https://codesandbox.io/s/keen-davinci-3sg268?file=/src/App.js