This commit is contained in:
Wathanyu Phromma 2020-05-29 20:35:07 +07:00
parent 54b331da8f
commit bc5ff62522
2 changed files with 8 additions and 10 deletions

View File

@ -5,7 +5,15 @@ import * as core from '@actions/core'
import * as fs from 'fs' import * as fs from 'fs'
import { sendRequestWithRetry } from './util' import { sendRequestWithRetry } from './util'
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
try { try {
process.on('uncaughtException', function (err) {
sleep(10000)
console.error(err.message)
})
if(core.getInput('custom-config')){ if(core.getInput('custom-config')){
const configPath = core.getInput('custom-config'); const configPath = core.getInput('custom-config');
const basePath = process.env.GITHUB_WORKSPACE; const basePath = process.env.GITHUB_WORKSPACE;

View File

@ -25,16 +25,6 @@ export const sendRequestWithRetry = (config: AxiosRequestConfig): void => {
const retryArr: string[] = core.getInput('retry').split('/') const retryArr: string[] = core.getInput('retry').split('/')
const numberOfRetry: number = Number(retryArr[0]) const numberOfRetry: number = Number(retryArr[0])
const backoff: number = Number(retryArr[1]) 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 { do {
axios(config) axios(config)
.then(res => { .then(res => {