diff --git a/.changeset/chilled-buckets-sneeze.md b/.changeset/chilled-buckets-sneeze.md index c0b61bfc8dc..d485e384f70 100644 --- a/.changeset/chilled-buckets-sneeze.md +++ b/.changeset/chilled-buckets-sneeze.md @@ -3,4 +3,4 @@ 'firebase': patch --- -Check navigator.userAgent, in addition to navigator.appVersion, when determining whether to work around an IndexedDb bug in Safari. Add check for Mobile/# in addition to Version/# to include WKWebView safari versions in this check. +Check navigator.userAgent, in addition to navigator.appVersion, when determining whether to work around an IndexedDb bug in Safari. diff --git a/packages/firestore/src/local/indexeddb_persistence.ts b/packages/firestore/src/local/indexeddb_persistence.ts index bdf66193344..a4f70458df3 100644 --- a/packages/firestore/src/local/indexeddb_persistence.ts +++ b/packages/firestore/src/local/indexeddb_persistence.ts @@ -977,7 +977,12 @@ export class IndexedDbPersistence implements Persistence { // to make sure it gets a chance to run. this.markClientZombied(); - if (isSafari() && (navigator.appVersion.match(/(?:Version|Mobile)\/1[456]/) || navigator.userAgent.match(/(?:Version|Mobile)\/1[456]/))) { + const safariIndexdbBugVersionRegex = /(?:Version|Mobile)\/1[456]/; + if ( + isSafari() && + (navigator.appVersion.match(safariIndexdbBugVersionRegex) || + navigator.userAgent.match(safariIndexdbBugVersionRegex)) + ) { // On Safari 14, 15, and 16, we do not run any cleanup actions as it might // trigger a bug that prevents Safari from re-opening IndexedDB during // the next page load.