From c733a73be6602a4ded4fcfd1b312405ef0395299 Mon Sep 17 00:00:00 2001 From: Tom Andersen Date: Mon, 6 May 2024 10:40:15 -0400 Subject: [PATCH] fix: Nonblocking rollback --- dev/src/transaction.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 34dd3f966..2eea7627c 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -516,16 +516,20 @@ export class Transaction implements firestore.Transaction { this._transactionIdPromise = undefined; this._prevTransactionId = transactionId; - try { - await this._firestore.request('rollback', request, this._requestTag); - } catch (err) { - logger( - 'Firestore.runTransaction', - this._requestTag, - 'Best effort to rollback failed with error:', - err - ); - } + // We don't need to wait for rollback to completed before continuing. + // If there are any locks held, then rollback will eventually release them. + // Rollback can be done concurrently thereby reducing latency caused by + // otherwise blocking. + this._firestore + .request('rollback', request, this._requestTag) + .catch(err => { + logger( + 'Firestore.runTransaction', + this._requestTag, + 'Best effort to rollback failed with error:', + err + ); + }); } /**