Skip to content

Commit 1de9c98

Browse files
authored
fix: inline function and associated type management (#417)
1 parent cf3b341 commit 1de9c98

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as core from '@actions/core';
2-
import axios, {isAxiosError} from 'axios';
2+
import axios, {isAxiosError, AxiosError} from 'axios';
33
import isRetryAllowed from 'is-retry-allowed';
44

55
import * as https from 'https'
@@ -55,7 +55,7 @@ async function obtainAccessToken(
5555
const exchangeTokenRequest = {
5656
id_token: idToken
5757
}
58-
58+
5959
const response = await postWithRetries(
6060
agent,
6161
endpoint,
@@ -85,7 +85,7 @@ async function postWithRetries(
8585
const result = await axios.post(
8686
endpoint.toString(),
8787
payload,
88-
{httpsAgent: agent, headers: { 'User-Agent': 'central-login-GHA'}},
88+
{httpsAgent: agent, headers: {'User-Agent': 'central-login-GHA'}},
8989
);
9090

9191
core.info(
@@ -97,16 +97,18 @@ async function postWithRetries(
9797
return result.data['accessToken'];
9898
} catch (error) {
9999
lastError = error;
100-
if (isRetryableError(error) && attempt < maxRetries) {
101-
continue;
100+
if (isAxiosError(error)) {
101+
if (isRetryableError(error) && attempt < maxRetries) {
102+
continue;
103+
}
102104
}
103105
return Promise.reject(error);
104106
}
105107
}
106108
return Promise.reject(lastError);
107109
}
108110

109-
function isRetryableError(error): boolean {
111+
function isRetryableError(error: AxiosError): boolean {
110112
core.warning(error);
111113
if (error.code === 'ECONNABORTED') {
112114
return false;

0 commit comments

Comments
 (0)