Skip to content

Commit 0abf211

Browse files
Ignore lease refresh failures for single-tab clients (#3163)
1 parent 6cd5ed1 commit 0abf211

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

packages/firestore/src/local/indexeddb_persistence.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,7 @@ export class IndexedDbPersistence implements Persistence {
305305
this.simpleDb = db;
306306
// NOTE: This is expected to fail sometimes (in the case of another tab already
307307
// having the persistence lock), so it's the first thing we should do.
308-
return this.updateClientMetadataAndTryBecomePrimary(
309-
this.forceOwningTab
310-
);
308+
return this.updateClientMetadataAndTryBecomePrimary();
311309
})
312310
.then(() => {
313311
if (!this.isPrimary && !this.allowTabSynchronization) {
@@ -404,9 +402,7 @@ export class IndexedDbPersistence implements Persistence {
404402
* primary state listener if the client either newly obtained or released its
405403
* primary lease.
406404
*/
407-
private updateClientMetadataAndTryBecomePrimary(
408-
forceOwningTab = false
409-
): Promise<void> {
405+
private updateClientMetadataAndTryBecomePrimary(): Promise<void> {
410406
return this.runTransaction(
411407
'updateClientMetadataAndTryBecomePrimary',
412408
'readwrite',
@@ -446,15 +442,15 @@ export class IndexedDbPersistence implements Persistence {
446442
}
447443
)
448444
.catch(e => {
445+
if (isIndexedDbTransactionError(e)) {
446+
logDebug(LOG_TAG, 'Failed to extend owner lease: ', e);
447+
// Proceed with the existing state. Any subsequent access to
448+
// IndexedDB will verify the lease.
449+
return this.isPrimary;
450+
}
451+
449452
if (!this.allowTabSynchronization) {
450-
if (isIndexedDbTransactionError(e)) {
451-
logDebug(LOG_TAG, 'Failed to extend owner lease: ', e);
452-
// Proceed with the existing state. Any subsequent access to
453-
// IndexedDB will verify the lease.
454-
return this.isPrimary;
455-
} else {
456-
throw e;
457-
}
453+
throw e;
458454
}
459455

460456
logDebug(

0 commit comments

Comments
 (0)