taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 7e33bc8c4ad2bb8479a6dd66212613963d4d6b08
parent ef5bfbe69f83bc5533d7ddfe3d154087ddb4b759
Author: Florian Dold <florian@dold.me>
Date:   Tue, 14 Jan 2025 20:17:55 +0100

idb-bridge: clear tx handle upon commit/rollback

Diffstat:
Mpackages/idb-bridge/src/bridge-idb.ts | 18++++++++++++------
Mpackages/idb-bridge/src/node-helper-sqlite3-impl.test.ts | 11+++--------
2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/packages/idb-bridge/src/bridge-idb.ts b/packages/idb-bridge/src/bridge-idb.ts @@ -2613,11 +2613,14 @@ export class BridgeIDBTransaction // we asynchronously roll back the backend transaction, // if necessary/possible. - const maybeBtx = this._backendTransaction; - if (maybeBtx) { - this._backend.rollback(maybeBtx).catch((e) => { - console.warn(`error during rollback: ${e}`); - }); + { + const maybeBtx = this._backendTransaction; + if (maybeBtx) { + this._backendTransaction = undefined; + this._backend.rollback(maybeBtx).catch((e) => { + console.warn(`error during rollback: ${e}`); + }); + } } // "Any object stores and indexes which were created during the @@ -2774,6 +2777,7 @@ export class BridgeIDBTransaction // Probably there is a more elegant way to do this by aborting the // beginTransaction call when the transaction was aborted. // That would require changing the DB backend API. + this._backend.rollback(newBackendTx).catch((e) => { console.error("error during rollback"); console.error(e); @@ -2890,7 +2894,9 @@ export class BridgeIDBTransaction // We only have a backend transaction if any requests were placed // against the transactions. if (this._backendTransaction) { - await this._backend.commit(this._backendTransaction); + const backendTx = this._backendTransaction; + this._backendTransaction = undefined; + await this._backend.commit(backendTx); } // We must exit the upgrade transaction here, so that the "complete" diff --git a/packages/idb-bridge/src/node-helper-sqlite3-impl.test.ts b/packages/idb-bridge/src/node-helper-sqlite3-impl.test.ts @@ -15,16 +15,11 @@ */ import test from "ava"; -import * as fs from "node:fs"; import { createNodeHelperSqlite3Impl } from "./node-helper-sqlite3-impl.js"; -test("sqlite3 helper", async (t) => { - const filename = "mytestdb.sqlite3"; - try { - fs.unlinkSync(filename); - } catch (e) { - // Do nothing. - } +// Serial test as it touches the FS. +test.serial("sqlite3 helper", async (t) => { + const filename = ":memory:"; const impl = await createNodeHelperSqlite3Impl(); const db = await impl.open(filename);