diff --git a/dist/index.js b/dist/index.js index ac1c5bf..aafe99d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -461,18 +461,23 @@ async function runCmd() { if (!done) { kill(child.pid); - const waitStart = Date.now(); - await wait(ms.seconds(RETRY_WAIT_SECONDS)); - debug(`Waited ${ms.seconds(Date.now() - waitStart)}s`); - debug(`Configured wait: ${ms.seconds(RETRY_WAIT_SECONDS)}s`); + await retryWait(); throw new Error(`Timeout of ${TIMEOUT_MINUTES}m hit`); } else if (exit > 0) { + await retryWait(); throw new Error(`Child_process exited with error`); } else { return; } } +async function retryWait() { + const waitStart = Date.now(); + await wait(ms.seconds(RETRY_WAIT_SECONDS)); + debug(`Waited ${ms.seconds(Date.now() - waitStart)}s`); + debug(`Configured wait: ${ms.seconds(RETRY_WAIT_SECONDS)}s`); +} + async function runAction() { for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) { try { diff --git a/src/index.js b/src/index.js index c0724b4..1c8934f 100644 --- a/src/index.js +++ b/src/index.js @@ -45,18 +45,23 @@ async function runCmd() { if (!done) { kill(child.pid); - const waitStart = Date.now(); - await wait(ms.seconds(RETRY_WAIT_SECONDS)); - debug(`Waited ${ms.seconds(Date.now() - waitStart)}s`); - debug(`Configured wait: ${ms.seconds(RETRY_WAIT_SECONDS)}s`); + await retryWait(); throw new Error(`Timeout of ${TIMEOUT_MINUTES}m hit`); } else if (exit > 0) { + await retryWait(); throw new Error(`Child_process exited with error`); } else { return; } } +async function retryWait() { + const waitStart = Date.now(); + await wait(ms.seconds(RETRY_WAIT_SECONDS)); + debug(`Waited ${ms.seconds(Date.now() - waitStart)}s`); + debug(`Configured wait: ${ms.seconds(RETRY_WAIT_SECONDS)}s`); +} + async function runAction() { for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) { try {