mirror of
https://github.com/nick-fields/retry.git
synced 2026-02-10 07:05:29 +00:00
fix: enforce RETRY_WAIT_SECONDS on both command timeout and error
This commit is contained in:
13
dist/index.js
vendored
13
dist/index.js
vendored
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user