From 688a7f36c700376441b2070dc5ad4961cdd5c02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Kis-Nagy?= Date: Thu, 2 Dec 2021 16:40:35 +0100 Subject: [PATCH] fix update failure caused by recent AWS changes --- .gitignore | 1 + src/commands/update.js | 6 +++++- src/tasks/wait-until-not-pending.js | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5616ce02..8fdfd5b7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ SpecRunner.html .grunt *.log .DS_Store +.idea diff --git a/src/commands/update.js b/src/commands/update.js index fc6723b2..fa095865 100644 --- a/src/commands/update.js +++ b/src/commands/update.js @@ -145,7 +145,11 @@ module.exports = function update(options, optionalLogger) { }, () => logger.logStage('waiting for IAM role propagation'), Promise - ); + ).then(result => { + logger.logStage('waiting for lambda resource allocation'); + return waitUntilNotPending(lambda, lambdaConfig.name, awsDelay, awsRetries) + .then(() => result); + }); } }, cleanup = function () { diff --git a/src/tasks/wait-until-not-pending.js b/src/tasks/wait-until-not-pending.js index 2790751b..0f20bfdb 100644 --- a/src/tasks/wait-until-not-pending.js +++ b/src/tasks/wait-until-not-pending.js @@ -1,6 +1,8 @@ const retry = require('oh-no-i-insist'); -module.exports = function waitUntilNotPending(lambda, functionName, timeout, retries) { +module.exports = async function waitUntilNotPending(lambda, functionName, timeout, retries) { 'use strict'; + await new Promise(resolve => setTimeout(resolve, timeout)); + return retry( () => { return lambda.getFunctionConfiguration({FunctionName: functionName}).promise() @@ -20,5 +22,3 @@ module.exports = function waitUntilNotPending(lambda, functionName, timeout, ret Promise ); }; - -