aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-core/src/refresh.ts38
1 files changed, 19 insertions, 19 deletions
diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts
index cb39e6588..01970f8bc 100644
--- a/packages/taler-wallet-core/src/refresh.ts
+++ b/packages/taler-wallet-core/src/refresh.ts
@@ -54,7 +54,6 @@ import {
makeErrorDetail,
NotificationType,
RefreshReason,
- TalerError,
TalerErrorCode,
TalerErrorDetail,
TalerPreciseTimestamp,
@@ -1344,35 +1343,36 @@ export async function processRefreshGroup(
throw Error("refresh blocked");
}
- // Process refresh sessions of the group in parallel.
logger.trace(
`processing refresh sessions for ${refreshGroup.oldCoinPubs.length} old coins`,
);
let errors: TalerErrorDetail[] = [];
let inShutdown = false;
- const ps = refreshGroup.oldCoinPubs.map((x, i) =>
- processRefreshSession(wex, refreshGroupId, i).catch((x) => {
+
+ // Process refresh sessions in sequence.
+ // In the future, we could parallelize request, in particular when multiple
+ // exchanges are involved.
+ // But we need to make sure that we write results to DB with high priority,
+ // otherwise we run into problems with very large refresh groups, where we'd first
+ // do many many network requests before even going to the DB.
+
+ for (let i = 0; i < refreshGroup.oldCoinPubs.length; i++) {
+ try {
+ await processRefreshSession(wex, refreshGroupId, i);
+ } catch (x) {
if (x instanceof CryptoApiStoppedError) {
inShutdown = true;
logger.info(
"crypto API stopped while processing refresh group, probably the wallet is currently shutting down.",
);
- return;
- }
- if (x instanceof TalerError) {
- logger.warn("process refresh session got exception (TalerError)");
- logger.warn(`exc ${x}`);
- logger.warn(`exc stack ${x.stack}`);
- logger.warn(`error detail: ${j2s(x.errorDetail)}`);
- } else {
- logger.warn("process refresh session got exception");
- logger.warn(`exc ${x}`);
- logger.warn(`exc stack ${x.stack}`);
+ break;
}
- errors.push(getErrorDetailFromException(x));
- }),
- );
- await Promise.all(ps);
+ const err = getErrorDetailFromException(x);
+ logger.warn(`exception in refresh session: ${j2s(err)}`);
+ errors.push(getErrorDetailFromException(err));
+ }
+ }
+
if (inShutdown) {
return TaskRunResult.finished();
}