@@ -14,6 +14,8 @@ import { getNavigatorLocks } from '../..//shared/navigator';
1414import { AsyncDatabaseConnection } from './AsyncDatabaseConnection' ;
1515import { SharedConnectionWorker , WebDBAdapter } from './WebDBAdapter' ;
1616import { WorkerWrappedAsyncDatabaseConnection } from './WorkerWrappedAsyncDatabaseConnection' ;
17+ import { WASQLiteVFS } from './wa-sqlite/WASQLiteConnection' ;
18+ import { ResolvedWASQLiteOpenFactoryOptions } from './wa-sqlite/WASQLiteOpenFactory' ;
1719import { ResolvedWebSQLOpenOptions } from './web-sql-flags' ;
1820
1921/**
@@ -48,6 +50,7 @@ export class LockedAsyncDatabaseAdapter
4850 protected _disposeTableChangeListener : ( ( ) => void ) | null = null ;
4951 private _config : ResolvedWebSQLOpenOptions | null = null ;
5052 protected pendingAbortControllers : Set < AbortController > ;
53+ protected requiresHolds : boolean | null ;
5154
5255 closing : boolean ;
5356 closed : boolean ;
@@ -59,6 +62,7 @@ export class LockedAsyncDatabaseAdapter
5962 this . pendingAbortControllers = new Set < AbortController > ( ) ;
6063 this . closed = false ;
6164 this . closing = false ;
65+ this . requiresHolds = null ;
6266 // Set the name if provided. We can query for the name if not available yet
6367 this . debugMode = options . debugMode ?? false ;
6468 if ( this . debugMode ) {
@@ -107,6 +111,10 @@ export class LockedAsyncDatabaseAdapter
107111 this . _config = await this . _db . getConfig ( ) ;
108112 await this . registerOnChangeListener ( this . _db ) ;
109113 this . iterateListeners ( ( cb ) => cb . initialized ?.( ) ) ;
114+ /**
115+ * This is only required for the long-lived shared IndexedDB connections.
116+ */
117+ this . requiresHolds = ( this . _config as ResolvedWASQLiteOpenFactoryOptions ) . vfs == WASQLiteVFS . IDBBatchAtomicVFS ;
110118 }
111119
112120 getConfiguration ( ) : ResolvedWebSQLOpenOptions {
@@ -229,11 +237,13 @@ export class LockedAsyncDatabaseAdapter
229237 if ( timoutId ) {
230238 clearTimeout ( timoutId ) ;
231239 }
232- const holdId = await this . baseDB . markHold ( ) ;
240+ const holdId = this . requiresHolds ? await this . baseDB . markHold ( ) : null ;
233241 try {
234242 return await callback ( ) ;
235243 } finally {
236- await this . baseDB . releaseHold ( holdId ) ;
244+ if ( holdId ) {
245+ await this . baseDB . releaseHold ( holdId ) ;
246+ }
237247 }
238248 }
239249 ) ;
0 commit comments