File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
packages/firestore/src/local Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -580,10 +580,33 @@ export class IndexedDbPersistence implements Persistence {
580
580
if ( currentLeaseIsValid ) {
581
581
if ( this . isLocalClient ( currentPrimary ) && this . networkEnabled ) {
582
582
return true ;
583
- } else if ( ! this . isLocalClient ( currentPrimary ) ) {
583
+ }
584
+
585
+ if ( ! this . isLocalClient ( currentPrimary ) ) {
586
+ if ( ! currentPrimary ! . allowTabSynchronization ) {
587
+ // Fail the `canActAsPrimary` check if the current leaseholder has
588
+ // not opted into multi-tab synchronization. If this happens at
589
+ // client startup, we reject the Promise returned by
590
+ // `enablePersistence()` and the user can continue to use Firestore
591
+ // with in-memory persistence.
592
+ // If this fails during a lease refresh, we will instead block the
593
+ // AsyncQueue from executing further operations. Note that this is
594
+ // acceptable since mixing & matching different `synchronizeTabs`
595
+ // settings is not supported.
596
+ //
597
+ // TODO(b/114226234): Remove this check when `synchronizeTabs` can
598
+ // no longer be turned off.
599
+ throw new FirestoreError (
600
+ Code . FAILED_PRECONDITION ,
601
+ PRIMARY_LEASE_EXCLUSIVE_ERROR_MSG
602
+ ) ;
603
+ }
604
+
584
605
return false ;
585
606
}
586
- } else if ( this . networkEnabled && this . inForeground ) {
607
+ }
608
+
609
+ if ( this . networkEnabled && this . inForeground ) {
587
610
return true ;
588
611
}
589
612
You can’t perform that action at this time.
0 commit comments