Skip to content

Commit b6f1fa8

Browse files
Retry all non-Firestore exceptions
Our users are still seeing IndexedDB errors on iOS 13 (using IONIC/Cordova). One of the possible reasons is that some environments might not throw DOMExceptions, which would lead us to not retry. This PR flips our logic around and only skips retries if the underlying exception is a non-Firestore exception. Fixes #2232
1 parent 4ecd58e commit b6f1fa8

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/firestore/src/local/simple_db.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -294,23 +294,23 @@ export class SimpleDb {
294294
// caller.
295295
await transaction.completionPromise;
296296
return transactionFnResult;
297-
} catch (e) {
297+
} catch (error) {
298298
// TODO(schmidt-sebastian): We could probably be smarter about this and
299299
// not retry exceptions that are likely unrecoverable (such as quota
300300
// exceeded errors).
301301
const retryable =
302302
idempotent &&
303-
isDomException(e) &&
303+
error.name !== 'FirestoreError' &&
304304
attemptNumber < TRANSACTION_RETRY_COUNT;
305305
debug(
306306
LOG_TAG,
307307
'Transaction failed with error: %s. Retrying: %s.',
308-
e.message,
308+
error.message,
309309
retryable
310310
);
311311

312312
if (!retryable) {
313-
return Promise.reject(e);
313+
return Promise.reject(error);
314314
}
315315
}
316316
}

packages/firestore/test/unit/local/simple_db.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import { PersistencePromise } from '../../../src/local/persistence_promise';
2929

3030
import { fail } from '../../../src/util/assert';
31+
import { Code, FirestoreError } from '../../../src/util/error';
3132

3233
use(chaiAsPromised);
3334

@@ -551,8 +552,8 @@ describe('SimpleDb', () => {
551552
await expect(
552553
db.runTransaction('readwrite-idempotent', ['users'], txn => {
553554
++attemptCount;
554-
txn.abort();
555-
return PersistencePromise.reject(new Error('Aborted'));
555+
txn.abort(new FirestoreError(Code.ABORTED, 'Aborted'));
556+
return PersistencePromise.reject(new Error());
556557
})
557558
).to.eventually.be.rejected;
558559

0 commit comments

Comments
 (0)