My Firestore web app sometimes hits the following error on iOS:
@firebase/firestore: Firestore (5.5.0): INTERNAL UNHANDLED ERROR: An internal error was encountered in the Indexed Database server
What is causing this and how do I fix it?
This is due to a bug in iOS versions >= 12.2 and < 13. See https://bugs.webkit.org/show_bug.cgi?id=197050 for details. The bug can occur when the page or app returns to the foreground after being in the background for some period of time. When the error occurs, IndexedDB is left in an unusable state, causing the Firestore SDK to generate the mentioned error and become unusable as well.
The only way to avoid the error is disabling persistence. If you require persistence to be enabled, the only way to potentially recover is to catch the error with a global window.onerror
handler and e.g. refresh the page:
window.onerror = function(error) {
if (error.indexOf("An internal error was encountered in the Indexed Database server") >= 0) {
// Refresh the page to restore IndexedDb to a working state.
window.location.reload();
}
};
More context: https://github.com/firebase/firebase-js-sdk/issues/1670
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With