Skip to content
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

Merged
merged 4 commits into from
Nov 1, 2023
Merged

Replace axios with @actions/http-client #1097

merged 4 commits into from
Nov 1, 2023

Conversation

mctofu
Copy link
Contributor

@mctofu mctofu commented Oct 31, 2023

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.

@mctofu mctofu marked this pull request as ready for review October 31, 2023 23:49
@mctofu mctofu requested a review from a team as a code owner October 31, 2023 23:49
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.
}: ${JSON.stringify(res.result)}`
)
}
if (res.result == null) {
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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

Copy link
Contributor Author

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>> => {
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulapopoola
Copy link
Member

abdulapopoola commented Nov 1, 2023

[Aside] will we need to remove axios totally?

mctofu and others added 3 commits November 1, 2023 16:56
Co-authored-by: AbdulFattaah Popoola <abdulapopoola@github.com>
@mctofu mctofu merged commit 3249400 into main Nov 1, 2023
9 checks passed
@mctofu mctofu deleted the mctofu/replace-axios branch November 1, 2023 17:32
@mctofu mctofu mentioned this pull request Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants