Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24964,7 +24964,7 @@ function runRetryCmd(inputs) {
});
});
}
function runCmd(attempt, inputs) {
function runCmd(attempt, inputs, retry_remaining) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var end_time, executable, timeout, child;
Expand Down Expand Up @@ -25011,20 +25011,24 @@ function runCmd(attempt, inputs) {
if (Date.now() < end_time && !done) return [3 /*break*/, 1];
_c.label = 4;
case 4:
if (!(!done && child.pid)) return [3 /*break*/, 6];
if (!(!done && child.pid)) return [3 /*break*/, 7];
timeout = true;
(0, tree_kill_1.default)(child.pid);
if (!retry_remaining) return [3 /*break*/, 6];
return [4 /*yield*/, (0, util_1.retryWait)(milliseconds_1.default.seconds(inputs.retry_wait_seconds))];
case 5:
_c.sent();
throw new Error("Timeout of ".concat((0, inputs_1.getTimeout)(inputs), "ms hit"));
case 6:
if (!(exit > 0)) return [3 /*break*/, 8];
return [4 /*yield*/, (0, util_1.retryWait)(milliseconds_1.default.seconds(inputs.retry_wait_seconds))];
_c.label = 6;
case 6: throw new Error("Timeout of ".concat((0, inputs_1.getTimeout)(inputs), "ms hit"));
case 7:
if (!(exit > 0)) return [3 /*break*/, 10];
if (!retry_remaining) return [3 /*break*/, 9];
return [4 /*yield*/, (0, util_1.retryWait)(milliseconds_1.default.seconds(inputs.retry_wait_seconds))];
case 8:
_c.sent();
throw new Error("Child_process exited with error code ".concat(exit));
case 8: return [2 /*return*/];
_c.label = 9;
case 9: throw new Error("Child_process exited with error code ".concat(exit));
case 10: return [2 /*return*/];
}
});
});
Expand All @@ -25046,7 +25050,7 @@ function runAction(inputs) {
_a.trys.push([3, 5, , 12]);
// just keep overwriting attempts output
(0, core_1.setOutput)(OUTPUT_TOTAL_ATTEMPTS_KEY, attempt);
return [4 /*yield*/, runCmd(attempt, inputs)];
return [4 /*yield*/, runCmd(attempt, inputs, attempt !== inputs.max_attempts)];
case 4:
_a.sent();
(0, core_1.info)("Command completed after ".concat(attempt, " attempt(s)."));
Expand Down
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function runRetryCmd(inputs: Inputs): Promise<void> {
}
}

async function runCmd(attempt: number, inputs: Inputs) {
async function runCmd(attempt: number, inputs: Inputs, retry_remaining: boolean) {
const end_time = Date.now() + getTimeout(inputs);
const executable = getExecutable(inputs);

Expand Down Expand Up @@ -116,10 +116,14 @@ async function runCmd(attempt: number, inputs: Inputs) {
if (!done && child.pid) {
timeout = true;
kill(child.pid);
await retryWait(ms.seconds(inputs.retry_wait_seconds));
if (retry_remaining) {
await retryWait(ms.seconds(inputs.retry_wait_seconds));
}
throw new Error(`Timeout of ${getTimeout(inputs)}ms hit`);
} else if (exit > 0) {
await retryWait(ms.seconds(inputs.retry_wait_seconds));
if (retry_remaining) {
await retryWait(ms.seconds(inputs.retry_wait_seconds));
}
throw new Error(`Child_process exited with error code ${exit}`);
} else {
return;
Expand All @@ -133,7 +137,7 @@ async function runAction(inputs: Inputs) {
try {
// just keep overwriting attempts output
setOutput(OUTPUT_TOTAL_ATTEMPTS_KEY, attempt);
await runCmd(attempt, inputs);
await runCmd(attempt, inputs, attempt !== inputs.max_attempts);
info(`Command completed after ${attempt} attempt(s).`);
break;
// eslint-disable-next-line
Expand Down