taler-typescript-core

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

commit 4e6b3f3c0dbc4eef8293c837363ad37ed0bf4f37
parent ff821e23caaa26e685eedce17504785f005c3b58
Author: Florian Dold <dold@taler.net>
Date:   Thu, 20 Aug 2026 14:22:53 +0200

wallet-core: release database during shutdown

Diffstat:
Mpackages/taler-wallet-core/src/requests.test.ts | 13+++++++++++--
Mpackages/taler-wallet-core/src/requests.ts | 2+-
Mpackages/taler-wallet-core/src/wallet.ts | 8++++++++
3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/packages/taler-wallet-core/src/requests.test.ts b/packages/taler-wallet-core/src/requests.test.ts @@ -54,8 +54,14 @@ const backendCases = [ ] as const; for (const [expectedBackend, makeRunner] of backendCases) { - test(`init response reports the ${expectedBackend} database backend`, async () => { + test(`init reports and shuts down the ${expectedBackend} database backend`, async () => { const db = await makeRunner(); + const closeDb = db.close.bind(db); + let closeCalls = 0; + db.close = async () => { + closeCalls++; + await closeDb(); + }; const http = { async fetch(): Promise<never> { throw Error("unexpected HTTP request"); @@ -81,8 +87,11 @@ for (const [expectedBackend, makeRunner] of backendCases) { if (initialized) { await wallet.client.call(WalletApiOperation.Shutdown, {}); } - await db.close(); + if (closeCalls === 0) { + await db.close(); + } } + assert.strictEqual(closeCalls, 1); }); } diff --git a/packages/taler-wallet-core/src/requests.ts b/packages/taler-wallet-core/src/requests.ts @@ -1782,7 +1782,7 @@ async function handleShutdown( _req: EmptyObject, ): Promise<EmptyObject> { logger.info(`Shutdown requested`); - wex.ws.stop(); + await wex.ws.shutdown(); return {}; } diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -1338,6 +1338,14 @@ export class InternalWalletState { }); } + /** Stop processing and release the database before shutdown completes. */ + async shutdown(): Promise<void> { + this.stop(); + await this.dbOperationGate.runExclusive(async () => { + await this.dbHandle.close(); + }); + } + /** * Run an async function after acquiring a list of locks, identified * by string tokens.