Skip to content

Ignore lease refresh failures for single-tab clients #3163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions packages/firestore/src/local/indexeddb_persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,7 @@ export class IndexedDbPersistence implements Persistence {
this.simpleDb = db;
// NOTE: This is expected to fail sometimes (in the case of another tab already
// having the persistence lock), so it's the first thing we should do.
return this.updateClientMetadataAndTryBecomePrimary(
this.forceOwningTab
);
return this.updateClientMetadataAndTryBecomePrimary();
})
.then(() => {
if (!this.isPrimary && !this.allowTabSynchronization) {
Expand Down Expand Up @@ -404,9 +402,7 @@ export class IndexedDbPersistence implements Persistence {
* primary state listener if the client either newly obtained or released its
* primary lease.
*/
private updateClientMetadataAndTryBecomePrimary(
forceOwningTab = false
): Promise<void> {
private updateClientMetadataAndTryBecomePrimary(): Promise<void> {
return this.runTransaction(
'updateClientMetadataAndTryBecomePrimary',
'readwrite',
Expand Down Expand Up @@ -446,15 +442,15 @@ export class IndexedDbPersistence implements Persistence {
}
)
.catch(e => {
if (isIndexedDbTransactionError(e)) {
logDebug(LOG_TAG, 'Failed to extend owner lease: ', e);
// Proceed with the existing state. Any subsequent access to
// IndexedDB will verify the lease.
return this.isPrimary;
}

if (!this.allowTabSynchronization) {
if (isIndexedDbTransactionError(e)) {
logDebug(LOG_TAG, 'Failed to extend owner lease: ', e);
// Proceed with the existing state. Any subsequent access to
// IndexedDB will verify the lease.
return this.isPrimary;
} else {
throw e;
}
throw e;
}

logDebug(
Expand Down