summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-04-22 23:42:29 +0200
committerFlorian Dold <florian@dold.me>2024-04-22 23:42:29 +0200
commit548b979485ff5d01d99313933839f1e88523e4b3 (patch)
treeeea974176aee94edaaec757c0f2887e63e2664d8
parent00095769c8f047ddad204c14379839efbbc8640d (diff)
downloadwallet-core-548b979485ff5d01d99313933839f1e88523e4b3.tar.gz
wallet-core-548b979485ff5d01d99313933839f1e88523e4b3.tar.bz2
wallet-core-548b979485ff5d01d99313933839f1e88523e4b3.zip
wallet-core: avoid unresolved promise rejection
-rw-r--r--packages/taler-util/src/errors.ts4
-rw-r--r--packages/taler-wallet-core/src/exchanges.ts2
-rw-r--r--packages/taler-wallet-core/src/shepherd.ts5
3 files changed, 9 insertions, 2 deletions
diff --git a/packages/taler-util/src/errors.ts b/packages/taler-util/src/errors.ts
index 4dea7e1b6..9378d25e8 100644
--- a/packages/taler-util/src/errors.ts
+++ b/packages/taler-util/src/errors.ts
@@ -278,6 +278,10 @@ export class TalerError<T = any> extends Error {
}
}
+export function safeStringifyException(e: any): string {
+ return JSON.stringify(getErrorDetailFromException(e), undefined, 2);
+}
+
/**
* Convert an exception (or anything that was thrown) into
* a TalerErrorDetail object.
diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts
index 4a784cebb..5f0c744e2 100644
--- a/packages/taler-wallet-core/src/exchanges.ts
+++ b/packages/taler-wallet-core/src/exchanges.ts
@@ -1166,7 +1166,7 @@ export async function fetchFreshExchange(
wex.ws.exchangeCache.clear();
}
- wex.taskScheduler.ensureRunning();
+ await wex.taskScheduler.ensureRunning();
await startUpdateExchangeEntry(wex, canonUrl, {
forceUpdate: options.forceUpdate,
diff --git a/packages/taler-wallet-core/src/shepherd.ts b/packages/taler-wallet-core/src/shepherd.ts
index f512d53a4..62133d4b9 100644
--- a/packages/taler-wallet-core/src/shepherd.ts
+++ b/packages/taler-wallet-core/src/shepherd.ts
@@ -36,6 +36,7 @@ import {
assertUnreachable,
getErrorDetailFromException,
j2s,
+ safeStringifyException,
} from "@gnu-taler/taler-util";
import { processBackupForProvider } from "./backup/index.js";
import {
@@ -231,7 +232,9 @@ export class TaskSchedulerImpl implements TaskScheduler {
}
startShepherdTask(taskId: TaskIdStr): void {
- this.ensureRunning();
+ this.ensureRunning().catch((e) => {
+ logger.error(`error running scheduler: ${safeStringifyException(e)}`);
+ });
// Run in the background, no await!
this.internalStartShepherdTask(taskId);
}