diff --git a/src/index.ts b/src/index.ts index 69467c0..b2523e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,15 @@ import * as core from '@actions/core' import * as fs from 'fs' import { sendRequestWithRetry } from './util' +function sleep(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + try { + process.on('uncaughtException', function (err) { + sleep(10000) + console.error(err.message) + }) if(core.getInput('custom-config')){ const configPath = core.getInput('custom-config'); const basePath = process.env.GITHUB_WORKSPACE; diff --git a/src/util.ts b/src/util.ts index 8fa3a45..68ce0d5 100644 --- a/src/util.ts +++ b/src/util.ts @@ -25,16 +25,6 @@ export const sendRequestWithRetry = (config: AxiosRequestConfig): void => { const retryArr: string[] = core.getInput('retry').split('/') const numberOfRetry: number = Number(retryArr[0]) const backoff: number = Number(retryArr[1]) - process.on('uncaughtException', function (err) { - countRetry += 1 - core.info(`retry: ${countRetry}`) - if (countRetry <= numberOfRetry) { - sleep(backoff) - } else { - core.setFailed(err.message) - } - process.exit(0) - }) do { axios(config) .then(res => {