Skip to content

Commit 9a571f1

Browse files
run close operation in mutex
1 parent 0f1cb7c commit 9a571f1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/web/src/db/adapters/wa-sqlite/WASQLiteConnection.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,15 @@ export class WASqliteConnection
387387

388388
async close() {
389389
this.broadcastChannel?.close();
390-
await this.sqliteAPI.close(this.dbP);
390+
await this.acquireExecuteLock(async () => {
391+
/**
392+
* Running the close operation inside the same execute mutex prevents errors like:
393+
* ```
394+
* unable to close due to unfinalized statements or unfinished backups
395+
* ```
396+
*/
397+
await this.sqliteAPI.close(this.dbP);
398+
});
391399
}
392400

393401
async registerOnTableChange(callback: OnTableChangeCallback) {

0 commit comments

Comments
 (0)