Skip to content

Commit

Permalink
fix(cli): command timing out without showing info (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-lakhdar authored Jul 26, 2021
1 parent c5fbe71 commit d898858
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/org/config/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export default class Monitor extends Command {

public async catch(err?: Error) {
const {flags} = this.parse(Monitor);
handleSnapshotError(err);
await this.config.runHook(
'analytics',
buildAnalyticsFailureHook(this, flags, err)
);
handleSnapshotError(err);
}

private async monitorSnapshot(snapshot: Snapshot) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/org/config/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export default class Preview extends Command {

public async catch(err?: Error) {
const {flags} = this.parse(Preview);
handleSnapshotError(err);
await this.config.runHook(
'analytics',
buildAnalyticsFailureHook(this, flags, err)
);
handleSnapshotError(err);
}

private async handleReportWithErrors(snapshot: Snapshot) {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/org/config/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ export default class Pull extends Command {

public async catch(err?: Error) {
const {flags} = this.parse(Pull);
handleSnapshotError(err);
this.displayAdditionalErrorMessage(err);
await this.config.runHook(
'analytics',
buildAnalyticsFailureHook(this, flags, err)
);
handleSnapshotError(err);
this.displayAdditionalErrorMessage(err);
}

private displayAdditionalErrorMessage(err?: Error) {
if (err instanceof SnapshotOperationTimeoutError) {
const snapshot = err.snapshot;
cli.info(
cli.log(
dedent`
Once the snapshot is created, you can pull it with the following command:
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/org/config/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export default class Push extends Command {

public async catch(err?: Error) {
const {flags} = this.parse(Push);
handleSnapshotError(err);
await this.config.runHook(
'analytics',
buildAnalyticsFailureHook(this, flags, err)
);
handleSnapshotError(err);
}

private async handleValidReport(
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/lib/snapshot/snapshotCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ export async function getTargetOrg(config: Config, target?: string) {

export function handleSnapshotError(err?: Error) {
if (err instanceof SnapshotOperationTimeoutError) {
cli.info(operationGettingTooMuchTimeMessage(err.snapshot));
cli.log(operationGettingTooMuchTimeMessage(err.snapshot));
} else {
throw err;
}
}

function operationGettingTooMuchTimeMessage(snapshot: Snapshot): string {
return dedent`Snapshot ${
return dedent`${
snapshot.latestReport.type
} operation is taking a long time to complete.
Run the following command to monitor the operation:
Expand Down

0 comments on commit d898858

Please sign in to comment.