Skip to content

Commit ea3d9a2

Browse files
Improve test hack (#2259)
* Improve test hack * Comment in test hack
1 parent 9d74ae6 commit ea3d9a2

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

packages/firestore/src/local/simple_db.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export class SimpleDb {
257257

258258
async runTransaction<T>(
259259
mode: SimpleDbTransactionMode,
260-
objectStores: string[],
260+
objectStores: string[],x
261261
transactionFn: (transaction: SimpleDbTransaction) => PersistencePromise<T>
262262
): Promise<T> {
263263
const readonly = mode.startsWith('readonly');
@@ -273,15 +273,18 @@ export class SimpleDb {
273273
objectStores
274274
);
275275
try {
276-
// TODO(schmidt-sebastian): Remove this code/comment or find a way to
277-
// make this a test-only setting.
278-
// // Horrible hack to verify that idempotent functions can be run more
279-
// // than once.
280-
// const transactionFnResult = (idempotent && attemptNumber === 1
281-
// ? transactionFn(transaction)
282-
// : PersistencePromise.resolve({} as T)
283-
// ).next(() => transactionFn(transaction))
284276
const transactionFnResult = transactionFn(transaction)
277+
// TODO(schmidt-sebastian): Remove this code/comment or find a way to
278+
// make this a test-only setting.
279+
// Horrible hack to verify that idempotent functions can be run more
280+
// than once.
281+
.next(result => {
282+
if (idempotent && attemptNumber == 1) {
283+
class DOMException {}
284+
throw new DOMException();
285+
}
286+
return result;
287+
})
285288
.catch(error => {
286289
// Abort the transaction if there was an error.
287290
transaction.abort(error);

0 commit comments

Comments
 (0)