aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-06-18 19:21:39 +0200
committerFlorian Dold <florian@dold.me>2024-06-18 19:21:39 +0200
commit6ab16c94f55e0ef23271f3211c298fe2d84ba1fa (patch)
tree0b0e6ac3afdc866e8d94f668f5fa40023643b35a
parent3913d0117bd034b5d7467eeed6b10c59dae90ce8 (diff)
downloadwallet-core-6ab16c94f55e0ef23271f3211c298fe2d84ba1fa.tar.xz
wallet-core: throttle more long-polling
-rw-r--r--packages/taler-wallet-core/src/pay-merchant.ts13
-rw-r--r--packages/taler-wallet-core/src/withdraw.ts16
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
index b5d2670ad..9e3b37c51 100644
--- 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
index 7ba69d2c1..930aa134b 100644
--- 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