Skip to content

Commit

Permalink
fix: fix "Cannot commit, no transaction is active" error in sql.js
Browse files Browse the repository at this point in the history
Closes: typeorm#9100
  • Loading branch information
Obiwan1995 committed Jul 22, 2022
1 parent bb33cd0 commit 7720a8b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/driver/sqljs/SqljsDriver.ts
Expand Up @@ -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 {
Expand Down

0 comments on commit 7720a8b

Please sign in to comment.