|
1 | | -import { BaseObserver, DBAdapter, DBAdapterListener, DBLockOptions, QueryResult, Transaction } from '@powersync/common'; |
2 | 1 | import { ANDROID_DATABASE_PATH, getDylibPath, IOS_LIBRARY_PATH, open, type DB } from '@op-engineering/op-sqlite'; |
| 2 | +import { BaseObserver, DBAdapter, DBAdapterListener, DBLockOptions, QueryResult, Transaction } from '@powersync/common'; |
3 | 3 | import Lock from 'async-lock'; |
4 | | -import { OPSQLiteConnection } from './OPSQLiteConnection'; |
5 | 4 | import { Platform } from 'react-native'; |
| 5 | +import { OPSQLiteConnection } from './OPSQLiteConnection'; |
6 | 6 | import { SqliteOptions } from './SqliteOptions'; |
7 | 7 |
|
8 | 8 | /** |
@@ -155,15 +155,14 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement |
155 | 155 | } |
156 | 156 | } |
157 | 157 |
|
158 | | - close() { |
159 | | - this.initialized.then(() => { |
160 | | - // Abort any pending operations |
161 | | - this.abortController.abort(); |
162 | | - this.readQueue = []; |
| 158 | + async close() { |
| 159 | + await this.initialized; |
| 160 | + // Abort any pending operations |
| 161 | + this.abortController.abort(); |
| 162 | + this.readQueue = []; |
163 | 163 |
|
164 | | - this.writeConnection!.close(); |
165 | | - this.readConnections!.forEach((c) => c.connection.close()); |
166 | | - }); |
| 164 | + this.writeConnection!.close(); |
| 165 | + this.readConnections!.forEach((c) => c.connection.close()); |
167 | 166 | } |
168 | 167 |
|
169 | 168 | async readLock<T>(fn: (tx: OPSQLiteConnection) => Promise<T>, options?: DBLockOptions): Promise<T> { |
|
0 commit comments