diff options
Diffstat (limited to 'packages/taler-wallet-core/src/exchanges.ts')
-rw-r--r-- | packages/taler-wallet-core/src/exchanges.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts index 1fb3a8795..43ab8ac4e 100644 --- a/packages/taler-wallet-core/src/exchanges.ts +++ b/packages/taler-wallet-core/src/exchanges.ts @@ -999,6 +999,9 @@ async function internalWaitReadyExchange( exchangeBaseUrl: canonUrl, }); while (true) { + if (wex.cancellationToken.isCancelled) { + throw Error("cancelled"); + } logger.info(`waiting for ready exchange ${canonUrl}`); const { exchange, exchangeDetails, retryInfo, scopeInfo } = await wex.db.runReadOnlyTx( @@ -1128,14 +1131,13 @@ export async function fetchFreshExchange( forceUpdate: options.forceUpdate, }); - return waitReadyExchange(wex, canonUrl, options); + return await waitReadyExchange(wex, canonUrl, options); } async function waitReadyExchange( wex: WalletExecutionContext, canonUrl: string, options: { - cancellationToken?: CancellationToken; forceUpdate?: boolean; expectedMasterPub?: string; } = {}, @@ -1155,6 +1157,11 @@ async function waitReadyExchange( } }); + const unregisterOnCancelled = wex.cancellationToken.onCancelled(() => { + cancelNotif(); + exchangeNotifFlag.raise(); + }); + try { const res = await internalWaitReadyExchange( wex, @@ -1165,6 +1172,7 @@ async function waitReadyExchange( logger.info("done waiting for ready exchange"); return res; } finally { + unregisterOnCancelled(); cancelNotif(); } } |