mirror of
https://git.mirrors.martin98.com/https://github.com/cyberman54/curl
synced 2026-04-13 04:47:04 +08:00
test
This commit is contained in:
29
src/util.ts
29
src/util.ts
@@ -19,28 +19,27 @@ export const buildOutput = (res: AxiosResponse<any>): string => {
|
||||
})
|
||||
}
|
||||
|
||||
export const sendRequestWithRetry = (config: AxiosRequestConfig) => {
|
||||
export const sendRequestWithRetry = async (config: AxiosRequestConfig) => {
|
||||
var exit = false
|
||||
var countRetry = 0
|
||||
const retryArr: string[] = core.getInput('retry').split('/')
|
||||
const numberOfRetry: number = Number(retryArr[0])
|
||||
const backoff: number = Number(retryArr[1])
|
||||
do {
|
||||
axios(config)
|
||||
.then(res => {
|
||||
try {
|
||||
const res = await axios(config)
|
||||
setOutput(res)
|
||||
exit = true
|
||||
} catch (err) {
|
||||
countRetry += 1
|
||||
core.info(`retry: ${countRetry}`)
|
||||
if (countRetry <= numberOfRetry) {
|
||||
//await sleep(backoff * 1000)
|
||||
} else {
|
||||
exit = true
|
||||
setOutput(res)
|
||||
})
|
||||
.catch(err => {
|
||||
countRetry += 1
|
||||
core.info(`retry: ${countRetry}`)
|
||||
if (countRetry <= numberOfRetry) {
|
||||
//await sleep(backoff * 1000)
|
||||
} else {
|
||||
exit = true
|
||||
core.setFailed(err)
|
||||
}
|
||||
})
|
||||
core.setFailed(err)
|
||||
}
|
||||
}
|
||||
} while (!exit)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user