Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-bananas-fry.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion packages/firestore/src/core/transaction_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class TransactionRunner<T> {
}

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;
Expand Down
13 changes: 13 additions & 0 deletions packages/firestore/test/integration/api/transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
/* -_- */
Expand Down
Loading