File tree Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @journeyapps/wa-sqlite ' : patch
3+ ---
4+
5+ Fix potential deadlocks and Failed to execute 'createSyncAccessHandle' on 'FileSystemFileHandle' errors.
Original file line number Diff line number Diff line change @@ -519,17 +519,24 @@ export class OPFSCoopSyncVFS extends FacadeVFS {
519519 this . _module . retryOps . push ( ( async ( ) => {
520520 // Acquire the Web Lock.
521521 file . persistentFile . handleLockReleaser = await this . #acquireLock( file . persistentFile ) ;
522-
523- // Get access handles for the database and releated files in parallel.
524- this . log ?. ( `creating access handles for ${ file . path } ` )
525- await Promise . all ( DB_RELATED_FILE_SUFFIXES . map ( async suffix => {
526- const persistentFile = this . persistentFiles . get ( file . path + suffix ) ;
527- if ( persistentFile ) {
528- persistentFile . accessHandle =
529- await persistentFile . fileHandle . createSyncAccessHandle ( ) ;
530- }
531- } ) ) ;
532- file . persistentFile . isRequestInProgress = false ;
522+ try {
523+ // Get access handles for the database and releated files in parallel.
524+ this . log ?. ( `creating access handles for ${ file . path } ` )
525+ await Promise . all ( DB_RELATED_FILE_SUFFIXES . map ( async suffix => {
526+ const persistentFile = this . persistentFiles . get ( file . path + suffix ) ;
527+ if ( persistentFile ) {
528+ persistentFile . accessHandle =
529+ await persistentFile . fileHandle . createSyncAccessHandle ( ) ;
530+ }
531+ } ) ) ;
532+ } catch ( e ) {
533+ this . log ?. ( `failed to create access handles for ${ file . path } ` , e ) ;
534+ // Close any of the potentially opened access handles
535+ this . #releaseAccessHandle( file ) ;
536+ throw e ;
537+ } finally {
538+ file . persistentFile . isRequestInProgress = false ;
539+ }
533540 } ) ( ) ) ;
534541 return this . _module . retryOps . at ( - 1 ) ;
535542 }
You can’t perform that action at this time.
0 commit comments