commit 6ab16c94f55e0ef23271f3211c298fe2d84ba1fa
parent 3913d0117bd034b5d7467eeed6b10c59dae90ce8
Author: Florian Dold <florian@dold.me>
Date: Tue, 18 Jun 2024 19:21:39 +0200
wallet-core: throttle more long-polling
Diffstat:
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts
@@ -3028,12 +3028,17 @@ async function processPurchaseAutoRefund(
download.contractData.contractTermsHash,
);
- requestUrl.searchParams.set("timeout_ms", "10000");
requestUrl.searchParams.set("refund", Amounts.stringify(totalKnownRefund));
- const resp = await wex.http.fetch(requestUrl.href, {
- cancellationToken: wex.cancellationToken,
- });
+ const resp = await wex.ws.runLongpollQueueing(
+ requestUrl.hostname,
+ async (timeoutMs) => {
+ requestUrl.searchParams.set("timeout_ms", `${timeoutMs}`);
+ return await wex.http.fetch(requestUrl.href, {
+ cancellationToken: wex.cancellationToken,
+ });
+ },
+ );
// FIXME: Check other status codes!
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
@@ -824,12 +824,18 @@ async function processWithdrawalGroupDialogProposed(
);
url.searchParams.set("old_state", "pending");
- url.searchParams.set("long_poll_ms", "30000");
- const resp = await ctx.wex.http.fetch(url.href, {
- method: "GET",
- cancellationToken: ctx.wex.cancellationToken,
- });
+ const res = await ctx.wex.ws.runLongpollQueueing(
+ url.hostname,
+ async (timeoutMs) => {
+ url.searchParams.set("long_poll_ms", `${timeoutMs}`);
+
+ return await ctx.wex.http.fetch(url.href, {
+ method: "GET",
+ cancellationToken: ctx.wex.cancellationToken,
+ });
+ },
+ );
// If the bank claims that the withdrawal operation is already
// pending, but we're still in DialogProposed, some other wallet