From e60adb04a9cdc6908101b26e7087d6c71da000fa Mon Sep 17 00:00:00 2001 From: Niklas Fondberg Date: Thu, 18 Nov 2021 14:38:13 +0100 Subject: [PATCH] Fix non awaited promises (#88) --- cloudformation/ecs-service.yaml | 4 ++++ src/datasources/product-api.ts | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cloudformation/ecs-service.yaml b/cloudformation/ecs-service.yaml index 7523e6f..0903c1f 100644 --- a/cloudformation/ecs-service.yaml +++ b/cloudformation/ecs-service.yaml @@ -190,6 +190,10 @@ Resources: - 'comprehend:DetectDominantLanguage' - 'translate:TranslateText' Resource: '*' + - Effect: Allow + Action: + - 'sqs:SendMessage' + Resource: !Sub arn:aws:sqs:eu-west-1:954747537408:photowall-bernard-${EnvironmentName} # A role for the containers TaskRole: diff --git a/src/datasources/product-api.ts b/src/datasources/product-api.ts index ae00070..9e0fad1 100644 --- a/src/datasources/product-api.ts +++ b/src/datasources/product-api.ts @@ -407,22 +407,25 @@ export class ProductAPI extends BaseSQLDataSource { productId: number, info: ProductInfoInput, ): Promise { + const promises = []; + // Check path and insert new unique path if taken const uniquePath = await this.getUniqueProductPath(info.path, productId); const oldProd = await this.getProduct(productId); if (oldProd.path !== uniquePath) { - sendPathChangedCmd(oldProd.path, uniquePath); + const promise = sendPathChangedCmd(oldProd.path, uniquePath); + promises.push(promise); } if (oldProd.fields.name !== info.name) { - await this.textsApi.translateProductName( + const promise = this.textsApi.translateProductName( info.name, oldProd.path, uniquePath, ); + promises.push(promise); } - const promises = []; promises.push( this.knex .table('product-products')