From 7720a8b88741c93690a85e0e242e3c51a631936b Mon Sep 17 00:00:00 2001 From: Brice Miclo Date: Fri, 22 Jul 2022 16:54:36 +0200 Subject: [PATCH] fix: fix "Cannot commit, no transaction is active" error in sql.js Closes: #9100 --- src/driver/sqljs/SqljsDriver.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/driver/sqljs/SqljsDriver.ts b/src/driver/sqljs/SqljsDriver.ts index 7e24c042b0..a63a932791 100644 --- a/src/driver/sqljs/SqljsDriver.ts +++ b/src/driver/sqljs/SqljsDriver.ts @@ -199,9 +199,10 @@ export class SqljsDriver extends AbstractSqliteDriver { * If a custom autoSaveCallback is specified, it get's called with the database as Uint8Array, * otherwise the save method is called which saves it to file (Node.js), local storage (browser) * or indexedDB (browser with enabled useLocalForage option). + * Don't auto-save when in transaction as the call to export will end the current transaction */ async autoSave() { - if (this.options.autoSave) { + if (this.options.autoSave && !this.queryRunner?.isTransactionActive) { if (this.options.autoSaveCallback) { await this.options.autoSaveCallback(this.export()) } else {