taler-typescript-core

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

commit e3531701fb8c9552da67d3a4c7a0d2fce5d4ec30
parent 82e591c3d1444cd548d4dee82c4b55f9b51465f1
Author: Florian Dold <dold@taler.net>
Date:   Wed, 22 Jul 2026 10:50:19 +0200

wallet: release remote requests and notification conditions

Answered requests stayed in the request map and satisfied conditions were
re-evaluated on every later notification.  A disconnect now rejects the
requests in flight instead of leaving them pending forever.

Diffstat:
Mpackages/taler-wallet-core/src/remote.ts | 15+++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)

diff --git a/packages/taler-wallet-core/src/remote.ts b/packages/taler-wallet-core/src/remote.ts @@ -97,6 +97,17 @@ export async function createRemoteWallet( result: ctx, onDisconnect() { logger.info(`${args.name}: remote wallet disconnected`); + // None of the requests in flight can be answered anymore. + for (const h of requestMap.values()) { + h.promiseCapability.reject( + TalerError.fromDetail( + TalerErrorCode.WALLET_CORE_REQUEST_CANCELLED, + {}, + "remote wallet disconnected", + ), + ); + } + requestMap.clear(); }, onMessage(m) { // FIXME: use a codec for parsing the response envelope! @@ -121,6 +132,7 @@ export async function createRemoteWallet( ); return; } + requestMap.delete(id); h.promiseCapability.resolve(m as any); } else if (type === "notification") { if (args.notificationHandler) { @@ -210,6 +222,9 @@ export function makeNotificationWaiter(): WalletNotificationWaiter { condMap.forEach((cond, condKey) => { const res = cond.condition(n); if (res) { + // The promise settles once, so the condition must not be + // re-evaluated on later notifications. + condMap.delete(condKey); cond.promiseCapability.resolve(res); } });