From e9b7f1b274ea33851aee58898eb985a4094658fc Mon Sep 17 00:00:00 2001 From: Marek Gilbert Date: Tue, 15 Oct 2019 09:28:42 -0700 Subject: [PATCH] Mark acknowledgeBatch and rejectBatch idempotent --- packages/firestore/src/local/indexeddb_mutation_queue.ts | 4 +++- packages/firestore/src/local/local_store.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/firestore/src/local/indexeddb_mutation_queue.ts b/packages/firestore/src/local/indexeddb_mutation_queue.ts index 1c53f346543..75d75de91c8 100644 --- a/packages/firestore/src/local/indexeddb_mutation_queue.ts +++ b/packages/firestore/src/local/indexeddb_mutation_queue.ts @@ -497,7 +497,9 @@ export class IndexedDbMutationQueue implements MutationQueue { this.userId, batch ).next(removedDocuments => { - this.removeCachedMutationKeys(batch.batchId); + transaction.addOnCommittedListener(() => { + this.removeCachedMutationKeys(batch.batchId); + }); return PersistencePromise.forEach( removedDocuments, (key: DocumentKey) => { diff --git a/packages/firestore/src/local/local_store.ts b/packages/firestore/src/local/local_store.ts index b944e86c566..ba117046c3a 100644 --- a/packages/firestore/src/local/local_store.ts +++ b/packages/firestore/src/local/local_store.ts @@ -389,7 +389,7 @@ export class LocalStore { ): Promise { return this.persistence.runTransaction( 'Acknowledge batch', - 'readwrite-primary', + 'readwrite-primary-idempotent', txn => { const affected = batchResult.batch.keys(); const documentBuffer = this.remoteDocuments.newChangeBuffer({ @@ -416,7 +416,7 @@ export class LocalStore { rejectBatch(batchId: BatchId): Promise { return this.persistence.runTransaction( 'Reject batch', - 'readwrite-primary', + 'readwrite-primary-idempotent', txn => { let affectedKeys: DocumentKeySet; return this.mutationQueue