mirror of
https://github.com/nick-fields/retry.git
synced 2026-02-11 23:55:28 +00:00
patch: added debugging for issue #5
This commit is contained in:
11
src/index.js
11
src/index.js
@@ -1,4 +1,4 @@
|
||||
const { getInput, error, warning, info } = require('@actions/core');
|
||||
const { getInput, error, warning, info, debug } = require('@actions/core');
|
||||
const { spawn } = require('child_process');
|
||||
const { join } = require('path');
|
||||
const ms = require('milliseconds');
|
||||
@@ -23,7 +23,7 @@ const RETRY_WAIT_SECONDS = getInputNumber('retry_wait_seconds', false);
|
||||
const POLLING_INTERVAL_SECONDS = getInputNumber('polling_interval_seconds', false);
|
||||
|
||||
async function wait(ms) {
|
||||
return new Promise(r => setTimeout(r, ms));
|
||||
return new Promise((r) => setTimeout(r, ms));
|
||||
}
|
||||
|
||||
async function runCmd() {
|
||||
@@ -32,7 +32,7 @@ async function runCmd() {
|
||||
|
||||
var child = spawn('node', [join(__dirname, 'exec.js'), COMMAND], { stdio: 'inherit' });
|
||||
|
||||
child.on('exit', code => {
|
||||
child.on('exit', (code) => {
|
||||
if (code > 0) {
|
||||
exit = code;
|
||||
}
|
||||
@@ -45,7 +45,10 @@ 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`);
|
||||
throw new Error(`Timeout of ${TIMEOUT_MINUTES}m hit`);
|
||||
} else if (exit > 0) {
|
||||
throw new Error(`Child_process exited with error`);
|
||||
@@ -70,7 +73,7 @@ async function runAction() {
|
||||
}
|
||||
}
|
||||
|
||||
runAction().catch(err => {
|
||||
runAction().catch((err) => {
|
||||
error(err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user