Skip to content

Commit

Permalink
fix: Nonblocking rollback (#2039)
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-andersen committed May 6, 2024
1 parent 2c726a1 commit 52099c8
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions dev/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
});
}

/**
Expand Down

0 comments on commit 52099c8

Please sign in to comment.