Skip to content

Commit 42ed26d

Browse files
committed
Fix empty message reject in transaction body
1 parent 56fbe52 commit 42ed26d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/firestore/src/core/transaction_runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class TransactionRunner<T> {
113113
}
114114

115115
private isRetryableTransactionError(error: Error): boolean {
116-
if (error.name === 'FirebaseError') {
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)