Skip to content

Commit fb762b2

Browse files
Call commit() if available
1 parent bf93a38 commit fb762b2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/firestore/src/local/simple_db.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ export class SimpleDbTransaction {
121121
}
122122
}
123123

124+
maybeCommit(): void {
125+
// If the browser supports V3 indexedDb, invoke commit() explicitly to
126+
// speed up index DB processing if the event loop remains blocks.
127+
const maybeV3IndexedDb = this.transaction as any;
128+
if (typeof maybeV3IndexedDb.commit === 'function') {
129+
maybeV3IndexedDb.commit();
130+
}
131+
}
132+
124133
/**
125134
* Returns a SimpleDbStore<KeyType, ValueType> for the specified store. All
126135
* operations performed on the SimpleDbStore happen within the context of this
@@ -400,6 +409,10 @@ export class SimpleDb {
400409
objectStores
401410
);
402411
const transactionFnResult = transactionFn(transaction)
412+
.next(result => {
413+
transaction.maybeCommit();
414+
return result;
415+
})
403416
.catch(error => {
404417
// Abort the transaction if there was an error.
405418
transaction.abort(error);

0 commit comments

Comments
 (0)