@@ -18,20 +18,20 @@ import { mutexRunExclusive } from '../utils/mutex.js';
1818import { throttleTrailing } from '../utils/throttle.js' ;
1919import { SQLOpenFactory , SQLOpenOptions , isDBAdapter , isSQLOpenFactory , isSQLOpenOptions } from './SQLOpenFactory.js' ;
2020import { PowerSyncBackendConnector } from './connection/PowerSyncBackendConnector.js' ;
21+ import { runOnSchemaChange } from './runOnSchemaChange.js' ;
2122import { BucketStorageAdapter , PSInternalTable } from './sync/bucket/BucketStorageAdapter.js' ;
2223import { CrudBatch } from './sync/bucket/CrudBatch.js' ;
2324import { CrudEntry , CrudEntryJSON } from './sync/bucket/CrudEntry.js' ;
2425import { CrudTransaction } from './sync/bucket/CrudTransaction.js' ;
2526import {
2627 DEFAULT_CRUD_UPLOAD_THROTTLE_MS ,
27- type AdditionalConnectionOptions ,
28- type PowerSyncConnectionOptions ,
28+ DEFAULT_RETRY_DELAY_MS ,
2929 StreamingSyncImplementation ,
3030 StreamingSyncImplementationListener ,
31- DEFAULT_RETRY_DELAY_MS ,
31+ type AdditionalConnectionOptions ,
32+ type PowerSyncConnectionOptions ,
3233 type RequiredAdditionalConnectionOptions
3334} from './sync/stream/AbstractStreamingSyncImplementation.js' ;
34- import { runOnSchemaChange } from './runOnSchemaChange.js' ;
3535
3636export interface DisconnectAndClearOptions {
3737 /** When set to false, data in local-only tables is preserved. */
@@ -505,6 +505,10 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
505505 async close ( options : PowerSyncCloseOptions = DEFAULT_POWERSYNC_CLOSE_OPTIONS ) {
506506 await this . waitForReady ( ) ;
507507
508+ if ( this . closed ) {
509+ return ;
510+ }
511+
508512 const { disconnect } = options ;
509513 if ( disconnect ) {
510514 await this . disconnect ( ) ;
0 commit comments