Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): deployment errors are printed 3 times #31389

Merged
merged 17 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/aws-cdk/lib/api/deployments.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as cxapi from '@aws-cdk/cx-api';
import * as cdk_assets from 'cdk-assets';
import { AssetManifest, IManifestEntry } from 'cdk-assets';
import * as chalk from 'chalk';
import { Mode } from './aws-auth/credentials';
import { ISDK } from './aws-auth/sdk';
import { CredentialsOptions, SdkForEnvironment, SdkProvider } from './aws-auth/sdk-provider';
Expand Down Expand Up @@ -692,7 +693,7 @@ export class Deployments {
if (existing) {
return existing;
}
const prefix = stackName ? `${stackName}: ` : '';
const prefix = stackName ? `${chalk.bold(stackName)}: ` : '';
const publisher = new cdk_assets.AssetPublishing(assetManifest, {
aws: new PublishingAws(this.sdkProvider, env),
progressListener: new ParallelSafeAssetProgress(prefix, this.props.quiet ?? false),
Expand All @@ -711,7 +712,7 @@ class ParallelSafeAssetProgress implements cdk_assets.IPublishProgressListener {

public onPublishEvent(type: cdk_assets.EventType, event: cdk_assets.IPublishProgress): void {
const handler = this.quiet && type !== 'fail' ? debug : EVENT_TO_LOGGER[type];
handler(`${this.prefix} ${type}: ${event.message}`);
handler(`${this.prefix}${type}: ${event.message}`);
}
}

Expand Down
11 changes: 5 additions & 6 deletions packages/aws-cdk/lib/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,6 @@ export class CdkToolkit {
print('Stack ARN:');

data(result.stackArn);
} catch (e) {
error('\n ❌ %s failed: %s', chalk.bold(stack.displayName), e);
throw e;
} finally {
if (options.cloudWatchLogMonitor) {
const foundLogGroupsResult = await findCloudWatchLogGroups(this.props.sdkProvider, stack);
Expand Down Expand Up @@ -427,9 +424,11 @@ export class CdkToolkit {
buildAsset,
publishAsset,
});
} catch (e) {
error('\n ❌ Deployment failed: %s', e);
throw e;
} catch (e: any) {
error('\n ❌ Deployment failed: %s', e.message);
throw new Error('There was an error deploying (see above for details)');
}
}
}
}

Expand Down
Loading