diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-08-20 16:27:20 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-08-20 16:27:20 +0530 |
commit | 421e613f92b80c81c856d6b074aa160e80e38e3d (patch) | |
tree | 7284e8b856986de3ee4ca1362fa9b52ce1e22de1 /packages/taler-wallet-core/src/operations/refresh.ts | |
parent | ddf9171c5becb3bb1aebdd3e1a298644f62ed090 (diff) | |
download | wallet-core-421e613f92b80c81c856d6b074aa160e80e38e3d.tar.xz |
throttling diagnostics and request timeouts
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/refresh.ts | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index 430675328..89cc3af43 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -42,7 +42,7 @@ import { import { guardOperationException } from "./errors"; import { NotificationType } from "../types/notifications"; import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto"; -import { getTimestampNow } from "../util/time"; +import { getTimestampNow, Duration } from "../util/time"; import { readSuccessResponseJsonOrThrow, HttpResponse } from "../util/http"; import { codecForExchangeMeltResponse, @@ -211,6 +211,10 @@ async function refreshCreateSession( ws.notify({ type: NotificationType.RefreshStarted }); } +function getRefreshRequestTimeout(rg: RefreshGroupRecord): Duration { + return { d_ms: 5000 }; +} + async function refreshMelt( ws: InternalWalletState, refreshGroupId: string, @@ -249,12 +253,11 @@ async function refreshMelt( }; logger.trace(`melt request for coin:`, meltReq); - const resp = await ws.runSequentialized( - [EXCHANGE_COINS_LOCK], - async () => { - return await ws.http.postJson(reqUrl.href, meltReq); - }, - ); + const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], async () => { + return await ws.http.postJson(reqUrl.href, meltReq, { + timeout: getRefreshRequestTimeout(refreshGroup), + }); + }); const meltResponse = await readSuccessResponseJsonOrThrow( resp, @@ -346,12 +349,11 @@ async function refreshReveal( refreshSession.exchangeBaseUrl, ); - const resp = await ws.runSequentialized( - [EXCHANGE_COINS_LOCK], - async () => { - return await ws.http.postJson(reqUrl.href, req); - }, - ); + const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], async () => { + return await ws.http.postJson(reqUrl.href, req, { + timeout: getRefreshRequestTimeout(refreshGroup), + }); + }); const reveal = await readSuccessResponseJsonOrThrow( resp, |