Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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': patch
---

Fixed a bug where a rejected promise with an empty message in a transaction would cause a timeout.
4 changes: 2 additions & 2 deletions packages/firestore/src/core/transaction_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export class TransactionRunner<T> {
}
}

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