From 019fc4b89fca981f2935641c4fde0b2b0697138e Mon Sep 17 00:00:00 2001 From: Aaron DeRuvo Date: Thu, 28 Mar 2024 14:29:04 +0300 Subject: [PATCH] logging the error is noisy for the users --- packages/cli/package.json | 2 +- packages/cli/src/base.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 1a78c17ca..363d66a5d 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -29,7 +29,7 @@ "lint": "yarn run --top-level eslint -c .eslintrc.js ", "prepublish": "", "prepack": "yarn run build && oclif manifest && oclif readme", - "test": "yarn jest --runInBand --detectOpenHandles" + "test": "yarn jest --runInBand --silent --detectOpenHandles" }, "dependencies": { "@celo/abis": "11.0.0", diff --git a/packages/cli/src/base.ts b/packages/cli/src/base.ts index 0871a637a..945065c82 100644 --- a/packages/cli/src/base.ts +++ b/packages/cli/src/base.ts @@ -7,12 +7,15 @@ import { LocalWallet } from '@celo/wallet-local' import _TransportNodeHid from '@ledgerhq/hw-transport-node-hid' import { Command, Flags } from '@oclif/core' import chalk from 'chalk' +import debugFactory from 'debug' import net from 'net' import Web3 from 'web3' import { CustomFlags } from './utils/command' import { getNodeUrl } from './utils/config' import { requireNodeIsSynced } from './utils/helpers' +const debug = debugFactory('cli:base') + export abstract class BaseCommand extends Command { static flags = { privateKey: Flags.string({ @@ -232,10 +235,11 @@ export abstract class BaseCommand extends Command { async finally(arg: Error | undefined): Promise { try { if (arg) { - console.error('received error while cleaning up', arg) + debug('received error while cleaning up:', arg) } - const kit = await this.getKit() - kit.connection.stop() + // we only need to stop the kit if one exists. if there is an error on this.parse for flags then there is no kit and thus none to stop + // if we use this.getKit then this.parse is called and errors out. throwing and logging failed to close the connection + this._kit && this._kit.connection.stop() } catch (error) { this.log(`Failed to close the connection: ${error}`) }