File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
packages/web/src/db/adapters Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -305,14 +305,16 @@ export class LockedAsyncDatabaseAdapter
305305 protected async acquireLock ( callback : ( ) => Promise < any > , options ?: { timeoutMs ?: number } ) : Promise < any > {
306306 await this . waitForInitialized ( ) ;
307307
308+ // The database is being opened in the background. Wait for it here.
309+ if ( this . databaseOpenPromise ) {
310+ await this . databaseOpenPromise ;
311+ }
312+
308313 return this . _acquireLock ( async ( ) => {
309314 let holdId : string | null = null ;
310315 try {
311- // The database is being opened in the background. Wait for it here .
316+ // We can't await this since it uses the same lock as we're in now .
312317 if ( this . databaseOpenPromise ) {
313- /**
314- * We can't await this since it uses the same lock as we're in now.
315- */
316318 throw new ConnectionClosedError ( 'Connection is busy re-opening' ) ;
317319 }
318320
@@ -322,6 +324,7 @@ export class LockedAsyncDatabaseAdapter
322324 if ( ex instanceof ConnectionClosedError ) {
323325 if ( this . options . reOpenOnConnectionClosed && ! this . databaseOpenPromise && ! this . closing ) {
324326 // Immediately re-open the database. We need to miss as little table updates as possible.
327+ // Note, don't await this since it uses the same lock as we're in now.
325328 this . reOpenInternalDB ( ) ;
326329 }
327330 }
You can’t perform that action at this time.
0 commit comments