taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 548b979485ff5d01d99313933839f1e88523e4b3
parent 00095769c8f047ddad204c14379839efbbc8640d
Author: Florian Dold <florian@dold.me>
Date:   Mon, 22 Apr 2024 23:42:29 +0200

wallet-core: avoid unresolved promise rejection

Diffstat:
Mpackages/taler-util/src/errors.ts | 4++++
Mpackages/taler-wallet-core/src/exchanges.ts | 2+-
Mpackages/taler-wallet-core/src/shepherd.ts | 5++++-
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git 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 @@ -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 @@ -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); }