From 9d38cb56a6fa4c9a975df339cb0aa08f040368c1 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 24 Mar 2022 01:10:34 +0100 Subject: wallet: crypto worker fixes, better taler-crypto-worker integration --- packages/taler-wallet-cli/src/index.ts | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'packages/taler-wallet-cli') diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index 3b79f78b8..254dadf93 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -64,7 +64,10 @@ import { runBench1 } from "./bench1.js"; import { runEnv1 } from "./env1.js"; import { GlobalTestState, runTestWithState } from "./harness/harness.js"; import { runBench2 } from "./bench2.js"; -import { TalerCryptoInterface, TalerCryptoInterfaceR } from "@gnu-taler/taler-wallet-core/src/crypto/cryptoImplementation"; +import { + TalerCryptoInterface, + TalerCryptoInterfaceR, +} from "@gnu-taler/taler-wallet-core/src/crypto/cryptoImplementation"; // This module also serves as the entry point for the crypto // thread worker, and thus must expose these two handlers. @@ -75,6 +78,12 @@ export { const logger = new Logger("taler-wallet-cli.ts"); +process.on("unhandledRejection", (error: any) => { + logger.error("unhandledRejection", error.message); + logger.error("stack", error.stack); + process.exit(2); +}); + const defaultWalletDbPath = os.homedir + "/" + ".talerwalletdb.json"; function assertUnreachable(x: never): never { @@ -218,6 +227,7 @@ async function withWallet( } finally { logger.info("operation with wallet finished, stopping"); wallet.stop(); + logger.info("stopped wallet"); } } @@ -250,13 +260,18 @@ walletCli console.error("Invalid JSON"); process.exit(1); } - const resp = await wallet.ws.handleCoreApiRequest( - args.api.operation, - "reqid-1", - requestJson, - ); - console.log(JSON.stringify(resp, undefined, 2)); + try { + const resp = await wallet.ws.handleCoreApiRequest( + args.api.operation, + "reqid-1", + requestJson, + ); + console.log(JSON.stringify(resp, undefined, 2)); + } catch (e) { + logger.error(`Got exception while handling API request ${e}`); + } }); + logger.info("finished handling API request"); }); walletCli -- cgit v1.2.3