Skip to content

Commit

Permalink
Use userAgent instead of depricated appVersion to check for safari in…
Browse files Browse the repository at this point in the history
…dexDB bug. (#6899)
  • Loading branch information
KoryNunn committed Mar 7, 2023
1 parent 547348b commit 5099f0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilled-buckets-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@firebase/firestore': patch
'firebase': patch
---

Check navigator.userAgent, in addition to navigator.appVersion, when determining whether to work around an IndexedDb bug in Safari.
9 changes: 7 additions & 2 deletions packages/firestore/src/local/indexeddb_persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,13 @@ export class IndexedDbPersistence implements Persistence {
// to make sure it gets a chance to run.
this.markClientZombied();

if (isSafari() && navigator.appVersion.match(/Version\/1[45]/)) {
// On Safari 14 and 15, we do not run any cleanup actions as it might
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.
// See https://bugs.webkit.org/show_bug.cgi?id=226547
Expand Down

0 comments on commit 5099f0f

Please sign in to comment.