diff options
author | Florian Dold <florian@dold.me> | 2022-03-24 01:10:34 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-03-24 01:10:41 +0100 |
commit | 9d38cb56a6fa4c9a975df339cb0aa08f040368c1 (patch) | |
tree | cc2fac95abe164b9da325de34a256f14ece9d9c9 /packages/taler-wallet-cli/src/index.ts | |
parent | cc18751e72435544297de4f5b5a6b318fbba9cd1 (diff) |
wallet: crypto worker fixes, better taler-crypto-worker integration
Diffstat (limited to 'packages/taler-wallet-cli/src/index.ts')
-rw-r--r-- | packages/taler-wallet-cli/src/index.ts | 29 |
1 files changed, 22 insertions, 7 deletions
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<T>( } 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 |