Skip to content

Commit 2058432

Browse files
authored
fix(firestore): fix empty message reject inside transaction body (#9177)
1 parent 5501791 commit 2058432

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

.changeset/spotty-bananas-fry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/firestore': patch
3+
---
4+
5+
Fixed a bug where a rejected promise with an empty message in a transaction would cause a timeout.

packages/firestore/src/core/transaction_runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ export class TransactionRunner<T> {
112112
}
113113
}
114114

115-
private isRetryableTransactionError(error: Error): boolean {
116-
if (error.name === 'FirebaseError') {
115+
private isRetryableTransactionError(error: Error | undefined): boolean {
116+
if (error?.name === 'FirebaseError') {
117117
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
118118
// non-matching document versions with ABORTED. These errors should be retried.
119119
const code = (error as FirestoreError).code;

packages/firestore/test/integration/api/transactions.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,19 @@ apiDescribe('Database transactions', persistence => {
593593
}
594594
);
595595

596+
it('runTransaction with empty message reject inside', () => {
597+
return withTestDb(persistence, async db => {
598+
try {
599+
await runTransaction(db, () => {
600+
return Promise.reject();
601+
});
602+
expect.fail('transaction should fail');
603+
} catch (err) {
604+
expect(err).to.be.undefined;
605+
}
606+
});
607+
});
608+
596609
describe('must return a promise:', () => {
597610
const noop = (): void => {
598611
/* -_- */

0 commit comments

Comments
 (0)