Skip to content

Commit

Permalink
fix: catch no updates CFN error and fix CFN poller hang
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle committed Jun 18, 2021
1 parent a23ab9b commit 6ddb167
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 0 additions & 4 deletions packages/amplify-cli/src/context-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,3 @@ const getProjectSettings = (): ProjectSettings => {

return projectSettings;
};
export function persistContext(context: Context): void {
// write to the backend and current backend
// and get the frontend plugin to write to the config files.
}
4 changes: 1 addition & 3 deletions packages/amplify-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as fs from 'fs-extra';
import * as path from 'path';
import { logInput } from './conditional-local-logging-init';
import { print } from './context-extensions';
import { attachUsageData, constructContext, persistContext } from './context-manager';
import { attachUsageData, constructContext } from './context-manager';
import { displayBannerMessages } from './display-banner-messages';
import { constants } from './domain/constants';
import { Context } from './domain/context';
Expand Down Expand Up @@ -156,8 +156,6 @@ export async function run() {
context.usageData.emitSuccess();
}

persistContext(context);

// no command supplied defaults to help, give update notification at end of execution
if (input.command === 'help') {
// Checks for available update, defaults to a 1 day interval for notification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,16 @@ class CloudFormation {

const cfnCompleteStatus = 'stackUpdateComplete';
if (updateErr) {
console.error('Error updating cloudformation stack');
reject(updateErr);
if (self.pollForEvents) {
clearInterval(self.pollForEvents);
}
return reject(updateErr);
}
cfnModel.waitFor(cfnCompleteStatus, cfnStackCheckParams, completeErr => {
if (self.pollForEvents) {
clearInterval(self.pollForEvents);
}
if (completeErr) {
console.error('Error updating cloudformation stack');
this.collectStackErrors(cfnParentStackParams.StackName).then(() => reject(completeErr));
} else {
return self.updateamplifyMetaFileWithStackOutputs(stackName).then(() => resolve());
Expand Down Expand Up @@ -463,7 +464,7 @@ class CloudFormation {
cfnModel.deleteStack(cfnStackParams, deleteErr => {
if (deleteErr) {
console.log(`Error deleting stack ${stackName}`);
reject(deleteErr);
return reject(deleteErr);
}
cfnModel.waitFor(cfnDeleteStatus, cfnStackParams, completeErr => {
if (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,17 @@ export async function run(context: $TSContext, resourceDefinition: $TSObject) {

const nestedStack = await formNestedStack(context, context.amplify.getProjectDetails());

await updateCloudFormationNestedStack(context, nestedStack, resourcesToBeCreated, resourcesToBeUpdated);
try {
await updateCloudFormationNestedStack(context, nestedStack, resourcesToBeCreated, resourcesToBeUpdated);
} catch (err) {
if (err?.name === 'ValidationError' && err?.message === 'No updates are to be performed.') {
return;
} else {
throw err;
}
} finally {
spinner.stop();
}
}
}

Expand Down

0 comments on commit 6ddb167

Please sign in to comment.