Skip to content
Merged
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
21 changes: 12 additions & 9 deletions packages/firestore/src/local/simple_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class SimpleDb {

async runTransaction<T>(
mode: SimpleDbTransactionMode,
objectStores: string[],
objectStores: string[],x
transactionFn: (transaction: SimpleDbTransaction) => PersistencePromise<T>
): Promise<T> {
const readonly = mode.startsWith('readonly');
Expand All @@ -273,15 +273,18 @@ export class SimpleDb {
objectStores
);
try {
// TODO(schmidt-sebastian): Remove this code/comment or find a way to
// make this a test-only setting.
// // Horrible hack to verify that idempotent functions can be run more
// // than once.
// const transactionFnResult = (idempotent && attemptNumber === 1
// ? transactionFn(transaction)
// : PersistencePromise.resolve({} as T)
// ).next(() => transactionFn(transaction))
const transactionFnResult = transactionFn(transaction)
// TODO(schmidt-sebastian): Remove this code/comment or find a way to
// make this a test-only setting.
// Horrible hack to verify that idempotent functions can be run more
// than once.
.next(result => {
if (idempotent && attemptNumber == 1) {
class DOMException {}
throw new DOMException();
}
return result;
})
.catch(error => {
// Abort the transaction if there was an error.
transaction.abort(error);
Expand Down