@@ -3,6 +3,11 @@ import { FacadeVFS } from '../FacadeVFS.js';
3
3
import * as VFS from '../VFS.js' ;
4
4
import { WebLocksMixin } from '../WebLocksMixin.js' ;
5
5
6
+ const RETRYABLE_ERRORS = new Set ( [
7
+ 'TransactionInactiveError' ,
8
+ 'InvalidStateError'
9
+ ] ) ;
10
+
6
11
/**
7
12
* @typedef Metadata
8
13
* @property {string } name
@@ -717,21 +722,21 @@ export class IDBContext {
717
722
} ) ;
718
723
}
719
724
720
- // @ts -ignore
721
- // Create object store proxies.
722
- const objectStores = [ ...tx . objectStoreNames ] . map ( name => {
723
- return [ name , this . proxyStoreOrIndex ( tx . objectStore ( name ) ) ] ;
724
- } ) ;
725
-
726
725
try {
726
+ // @ts -ignore
727
+ // Create object store proxies.
728
+ const objectStores = [ ...tx . objectStoreNames ] . map ( name => {
729
+ return [ name , this . proxyStoreOrIndex ( tx . objectStore ( name ) ) ] ;
730
+ } ) ;
731
+
727
732
// Execute the function.
728
733
return await f ( Object . fromEntries ( objectStores ) ) ;
729
734
} catch ( e ) {
730
735
// Use a new transaction if this one was inactive. This will
731
736
// happen if the last request in the transaction completed
732
737
// in a previous task but the transaction has not yet committed.
733
- if ( ! i && e . name === 'TransactionInactiveError' ) {
734
- this . log ?. ( 'TransactionInactiveError , retrying' ) ;
738
+ if ( ! i && RETRYABLE_ERRORS . has ( e . name ) ) {
739
+ this . log ?. ( ` ${ e . name } , retrying` ) ;
735
740
tx = null ;
736
741
continue ;
737
742
}
0 commit comments