fix: enforce RETRY_WAIT_SECONDS on both command timeout and error

This commit is contained in:
Nick Fields
2020-06-17 13:52:49 -04:00
parent 88ea919f23
commit 3ded872743
2 changed files with 18 additions and 8 deletions

13
dist/index.js vendored
View File

@@ -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 {

View File

@@ -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 {