diff --git a/.changeset/spotty-bananas-fry.md b/.changeset/spotty-bananas-fry.md new file mode 100644 index 00000000000..dec4b44dfb7 --- /dev/null +++ b/.changeset/spotty-bananas-fry.md @@ -0,0 +1,5 @@ +--- +'@firebase/firestore': patch +--- + +Fixed a bug where a rejected promise with an empty message in a transaction would cause a timeout. diff --git a/packages/firestore/src/core/transaction_runner.ts b/packages/firestore/src/core/transaction_runner.ts index d9e679321b5..c20632c735b 100644 --- a/packages/firestore/src/core/transaction_runner.ts +++ b/packages/firestore/src/core/transaction_runner.ts @@ -112,8 +112,8 @@ export class TransactionRunner { } } - private isRetryableTransactionError(error: Error): boolean { - if (error.name === 'FirebaseError') { + private isRetryableTransactionError(error?: Error): boolean { + if (error?.name === 'FirebaseError') { // In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and // non-matching document versions with ABORTED. These errors should be retried. const code = (error as FirestoreError).code; diff --git a/packages/firestore/test/integration/api/transactions.test.ts b/packages/firestore/test/integration/api/transactions.test.ts index a4d30677a92..0decd1e5fca 100644 --- a/packages/firestore/test/integration/api/transactions.test.ts +++ b/packages/firestore/test/integration/api/transactions.test.ts @@ -593,6 +593,19 @@ apiDescribe('Database transactions', persistence => { } ); + it('runTransaction with empty message reject inside', () => { + return withTestDb(persistence, async db => { + try { + await runTransaction(db, () => { + return Promise.reject(); + }); + expect.fail('transaction should fail'); + } catch (err) { + expect(err).to.be.undefined; + } + }); + }); + describe('must return a promise:', () => { const noop = (): void => { /* -_- */