From 44953b13dab00f24bfe8d869223398ec84caaebf Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Thu, 11 Apr 2024 14:35:37 +0200 Subject: [PATCH] check for undefined in promiseWhile --- .github/actions/javascript/awaitStagingDeploys/index.js | 4 ++++ .github/libs/promiseWhile.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/.github/actions/javascript/awaitStagingDeploys/index.js b/.github/actions/javascript/awaitStagingDeploys/index.js index 1cb7934cfb91..d84c6df1a0d3 100644 --- a/.github/actions/javascript/awaitStagingDeploys/index.js +++ b/.github/actions/javascript/awaitStagingDeploys/index.js @@ -12738,6 +12738,10 @@ function promiseWhile(condition, action) { else { const actionResult = action?.(); console.info('[promiseWhile] promiseWhile() actionResult', actionResult); + if (!actionResult) { + resolve(); + return; + } Promise.resolve(actionResult).then(loop).catch(reject); } }; diff --git a/.github/libs/promiseWhile.ts b/.github/libs/promiseWhile.ts index 2fc53c34fec3..01c061096d64 100644 --- a/.github/libs/promiseWhile.ts +++ b/.github/libs/promiseWhile.ts @@ -13,6 +13,12 @@ function promiseWhile(condition: () => boolean, action: (() => Promise) | } else { const actionResult = action?.(); console.info('[promiseWhile] promiseWhile() actionResult', actionResult); + + if (!actionResult) { + resolve(); + return; + } + Promise.resolve(actionResult).then(loop).catch(reject); } };