From 42ed26da6f233a173a2d88969578a900cabc7a30 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Mon, 21 Jul 2025 14:59:05 -0400 Subject: [PATCH 1/5] Fix empty message reject in transaction body --- packages/firestore/src/core/transaction_runner.ts | 2 +- .../test/integration/api/transactions.test.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/firestore/src/core/transaction_runner.ts b/packages/firestore/src/core/transaction_runner.ts index d9e679321b5..da6f9e40a1d 100644 --- a/packages/firestore/src/core/transaction_runner.ts +++ b/packages/firestore/src/core/transaction_runner.ts @@ -113,7 +113,7 @@ export class TransactionRunner { } private isRetryableTransactionError(error: Error): boolean { - if (error.name === 'FirebaseError') { + 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 => { /* -_- */ From 99e6d5913132051e701e5bfc69b7bb3c6cdeeaa0 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Mon, 21 Jul 2025 15:27:20 -0400 Subject: [PATCH 2/5] add changeset --- .changeset/spotty-bananas-fry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/spotty-bananas-fry.md diff --git a/.changeset/spotty-bananas-fry.md b/.changeset/spotty-bananas-fry.md new file mode 100644 index 00000000000..d5cdc46e29e --- /dev/null +++ b/.changeset/spotty-bananas-fry.md @@ -0,0 +1,5 @@ +--- +'@firebase/firestore': major +--- + +Fixed a bug where a rejected promise with an empty message in a transaction would cause a timeout. (https://github.com/firebase/firebase-js-sdk/issues/9147) From b1a487395d448c7e1551b8ad8c5822e8d86dabe2 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Thu, 24 Jul 2025 13:30:16 -0400 Subject: [PATCH 3/5] address feedbacks --- .changeset/spotty-bananas-fry.md | 2 +- packages/firestore/src/core/transaction_runner.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/spotty-bananas-fry.md b/.changeset/spotty-bananas-fry.md index d5cdc46e29e..6c8bb531abd 100644 --- a/.changeset/spotty-bananas-fry.md +++ b/.changeset/spotty-bananas-fry.md @@ -1,5 +1,5 @@ --- -'@firebase/firestore': major +'@firebase/firestore': patch --- Fixed a bug where a rejected promise with an empty message in a transaction would cause a timeout. (https://github.com/firebase/firebase-js-sdk/issues/9147) diff --git a/packages/firestore/src/core/transaction_runner.ts b/packages/firestore/src/core/transaction_runner.ts index da6f9e40a1d..c20632c735b 100644 --- a/packages/firestore/src/core/transaction_runner.ts +++ b/packages/firestore/src/core/transaction_runner.ts @@ -112,7 +112,7 @@ export class TransactionRunner { } } - private isRetryableTransactionError(error: Error): boolean { + 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. From 56ca0e16790e3147feea7cae9de9efa38cb5efb5 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 29 Jul 2025 22:35:08 -0400 Subject: [PATCH 4/5] address feedbacks 2 --- .changeset/spotty-bananas-fry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/spotty-bananas-fry.md b/.changeset/spotty-bananas-fry.md index 6c8bb531abd..dec4b44dfb7 100644 --- a/.changeset/spotty-bananas-fry.md +++ b/.changeset/spotty-bananas-fry.md @@ -2,4 +2,4 @@ '@firebase/firestore': patch --- -Fixed a bug where a rejected promise with an empty message in a transaction would cause a timeout. (https://github.com/firebase/firebase-js-sdk/issues/9147) +Fixed a bug where a rejected promise with an empty message in a transaction would cause a timeout. From 4714c7a3772b456df9d08cc6415e101427a24e81 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 18 Aug 2025 12:58:58 -0600 Subject: [PATCH 5/5] PR feedback - error? to Error | undefined --- packages/firestore/src/core/transaction_runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/src/core/transaction_runner.ts b/packages/firestore/src/core/transaction_runner.ts index c20632c735b..5b2fc5819f7 100644 --- a/packages/firestore/src/core/transaction_runner.ts +++ b/packages/firestore/src/core/transaction_runner.ts @@ -112,7 +112,7 @@ export class TransactionRunner { } } - private isRetryableTransactionError(error?: Error): boolean { + private isRetryableTransactionError(error: Error | undefined): 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.