gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-typescript-core] 03/03: idb-bridge: clear tx handle upon commit/r


From: gnunet
Subject: [taler-typescript-core] 03/03: idb-bridge: clear tx handle upon commit/rollback
Date: Tue, 14 Jan 2025 20:18:04 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository taler-typescript-core.

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

    idb-bridge: clear tx handle upon commit/rollback
---
 packages/idb-bridge/src/bridge-idb.ts                  | 18 ++++++++++++------
 .../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
index 6552cee91..d33e3d684 100644
--- 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
index c1cdca3a3..3ed231190 100644
--- 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);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]