Skip to content

Commit

Permalink
fix: Make transaction rollback best effort. (#1967)
Browse files Browse the repository at this point in the history
* Make rollback best effort.

* Fix test
  • Loading branch information
tom-andersen committed Jan 5, 2024
1 parent d9c867f commit 1d76546
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 14 additions & 1 deletion dev/src/transaction.ts
Expand Up @@ -481,7 +481,20 @@ export class Transaction implements firestore.Transaction {
transaction: this._transactionId,
};

return this._firestore.request('rollback', request, this._requestTag);
const promise: Promise<void> = this._firestore.request(
'rollback',
request,
this._requestTag
);

return promise.catch(reason => {
logger(
'Firestore.runTransaction',
this._requestTag,
'Best effort to rollback failed with error:',
reason
);
});
}

/**
Expand Down
1 change: 0 additions & 1 deletion dev/test/transaction.ts
Expand Up @@ -574,7 +574,6 @@ describe('failed transactions', () => {
begin({transactionId: 'foo1'}),
commit('foo1', /* writes=*/ undefined, serverError),
rollback('foo1', serverError),
rollback('foo1'),
backoff(),
begin({
transactionId: 'foo2',
Expand Down

0 comments on commit 1d76546

Please sign in to comment.