File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
packages/firestore/src/local Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @firebase/firestore " : patch
3+ ---
4+
5+ On browsers that support IndexedDB V3, we now invoke ` transaction.commit() ` to speed up data processing.
Original file line number Diff line number Diff line change @@ -121,6 +121,16 @@ export class SimpleDbTransaction {
121121 }
122122 }
123123
124+ maybeCommit ( ) : void {
125+ // If the browser supports V3 IndexedDB, we invoke commit() explicitly to
126+ // speed up index DB processing if the event loop remains blocks.
127+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
128+ const maybeV3IndexedDb = this . transaction as any ;
129+ if ( ! this . aborted && typeof maybeV3IndexedDb . commit === 'function' ) {
130+ maybeV3IndexedDb . commit ( ) ;
131+ }
132+ }
133+
124134 /**
125135 * Returns a SimpleDbStore<KeyType, ValueType> for the specified store. All
126136 * operations performed on the SimpleDbStore happen within the context of this
@@ -400,6 +410,10 @@ export class SimpleDb {
400410 objectStores
401411 ) ;
402412 const transactionFnResult = transactionFn ( transaction )
413+ . next ( result => {
414+ transaction . maybeCommit ( ) ;
415+ return result ;
416+ } )
403417 . catch ( error => {
404418 // Abort the transaction if there was an error.
405419 transaction . abort ( error ) ;
You can’t perform that action at this time.
0 commit comments