-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace axios with @actions/http-client #1097
Conversation
Axios has issues with proxies & using the @actions client should behave better in actions enviroments. The built in retry behavior was not as robust so I've implemented retries manually.
4647f0e
to
faa5966
Compare
src/api-client.ts
Outdated
}: ${JSON.stringify(res.result)}` | ||
) | ||
} | ||
if (res.result == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider idiomatic JS
if(!res.result) {
) | ||
} | ||
|
||
return res.data.data.attributes | ||
return res.result.data.attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can any of these be falsy
and throw a null ref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't be expected so a null ref failing the job would be OK.
) | ||
} | ||
throw error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider adding semicolons at the end to avoid weird JS automatic semicolon injection bugs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, our formatter does not allow that
): Promise<TypedResponse<T>> { | ||
let attempt = 1 | ||
|
||
const execute = async (): Promise<TypedResponse<T>> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does the actions team handle retries? Do they have some utility we can reuse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's embedded in the library and not exported: https://github.com/actions/toolkit/blob/fe3e7ce9a7f995d29d1fcfd226a32bca407f9dc8/packages/http-client/src/index.ts#L444-L450
[Aside] will we need to remove |
Co-authored-by: AbdulFattaah Popoola <abdulapopoola@github.com>
faa5966
to
6079515
Compare
Axios has issues with proxies. Rather than trying to workaround these problems this swaps our http client to
@actions/http-client
which is designed to work in actions environments.The swap was pretty straightforward except the built in retry behavior was not as robust. We needed it to handle additional 5xx codes so I've implemented retries manually.