summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/withdraw.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/withdraw.ts')
-rw-r--r--packages/taler-wallet-core/src/withdraw.ts28
1 files changed, 20 insertions, 8 deletions
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
index 9cf1ad36d..bfcf23588 100644
--- a/packages/taler-wallet-core/src/withdraw.ts
+++ b/packages/taler-wallet-core/src/withdraw.ts
@@ -911,6 +911,7 @@ async function processPlanchetExchangeBatchRequest(
ws: InternalWalletState,
wgContext: WithdrawalGroupContext,
args: WithdrawalRequestBatchArgs,
+ cancellationToken: CancellationToken,
): Promise<WithdrawalBatchResult> {
const withdrawalGroup: WithdrawalGroupRecord = wgContext.wgRecord;
logger.info(
@@ -997,6 +998,8 @@ async function processPlanchetExchangeBatchRequest(
const resp = await ws.http.fetch(reqUrl, {
method: "POST",
body: batchReq,
+ cancellationToken,
+ timeout: Duration.fromSpec({ seconds: 40 }),
});
if (resp.status === HttpStatusCode.UnavailableForLegalReasons) {
await handleKycRequired(ws, withdrawalGroup, resp, 0, requestCoinIdxs);
@@ -1300,7 +1303,7 @@ async function processQueryReserve(
`got reserve status error, EC=${result.talerErrorResponse.code}`,
);
if (resp.status === HttpStatusCode.NotFound) {
- return TaskRunResult.backoff();
+ return TaskRunResult.longpollReturnedPending();
} else {
throwUnexpectedRequestError(resp, result.talerErrorResponse);
}
@@ -1491,6 +1494,7 @@ async function processWithdrawalGroupPendingKyc(
async function processWithdrawalGroupPendingReady(
ws: InternalWalletState,
withdrawalGroup: WithdrawalGroupRecord,
+ cancellationToken: CancellationToken,
): Promise<TaskRunResult> {
const { withdrawalGroupId } = withdrawalGroup;
const transactionId = constructTransactionIdentifier({
@@ -1553,10 +1557,15 @@ async function processWithdrawalGroupPendingReady(
const maxBatchSize = 100;
for (let i = 0; i < numTotalCoins; i += maxBatchSize) {
- const resp = await processPlanchetExchangeBatchRequest(ws, wgContext, {
- batchSize: maxBatchSize,
- coinStartIndex: i,
- });
+ const resp = await processPlanchetExchangeBatchRequest(
+ ws,
+ wgContext,
+ {
+ batchSize: maxBatchSize,
+ coinStartIndex: i,
+ },
+ cancellationToken,
+ );
let work: Promise<void>[] = [];
work = [];
for (let j = 0; j < resp.coinIdxs.length; j++) {
@@ -1688,7 +1697,11 @@ export async function processWithdrawalGroup(
);
case WithdrawalGroupStatus.PendingReady:
// Continue with the actual withdrawal!
- return await processWithdrawalGroupPendingReady(ws, withdrawalGroup);
+ return await processWithdrawalGroupPendingReady(
+ ws,
+ withdrawalGroup,
+ cancellationToken,
+ );
case WithdrawalGroupStatus.AbortingBank:
return await processWithdrawalGroupAbortingBank(ws, withdrawalGroup);
case WithdrawalGroupStatus.AbortedBank:
@@ -2265,8 +2278,7 @@ async function processReserveBankStatus(
}
if (!status.transfer_done) {
- // FIXME: This is a long-poll result
- return TaskRunResult.backoff();
+ return TaskRunResult.longpollReturnedPending();
}
const transitionInfo = await ws.db.runReadWriteTx(