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

replaced single-shot HTTP requests with RETRY() #113

Closed
wants to merge 7 commits into from
Closed

replaced single-shot HTTP requests with RETRY() #113

wants to merge 7 commits into from

Conversation

jameslamb
Copy link

Thanks for for this awesome project!

In this PR, I'd like to propose swapping out calls to httr::POST() etc. with httr::RETRY(). This will make the package more resilient to transient problems like brief network outages or periods where the service(s) it hits are overwhelmed. In my experience, using retry logic almost always improves the user experience with HTTP clients. httr::RETRY() is awesome...it already implements exponential backoff and if you want you can customize things like how many retries it attempts and how long it's willing to wait between retries.

I'm working on chircollab/chircollab20#1 as part of Chicago R Collab, an R 'unconference' in Chicago.

Thanks for your time and consideration.

@codecov-commenter
Copy link

Codecov Report

Merging #113 into master will decrease coverage by 6.16%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
- Coverage   51.54%   45.37%   -6.17%     
==========================================
  Files          12       12              
  Lines         454      454              
==========================================
- Hits          234      206      -28     
- Misses        220      248      +28     
Impacted Files Coverage Δ
R/package.R 58.82% <83.33%> (-8.83%) ⬇️
R/gh_whoami.R 41.17% <0.00%> (-58.83%) ⬇️
R/gh_response.R 42.37% <0.00%> (-25.43%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update faf4206...547cf07. Read the comment docs.

@jameslamb
Copy link
Author

I've rebased this to pick up the changes merged into this project in the time since this pull request was opened.

@jameslamb
Copy link
Author

I just merged in the latest changes from master and fixed merge conflicts.

Are you open to this pull request? If not, I'd be happy to close it.

@gaborcsardi gaborcsardi mentioned this pull request Nov 9, 2020
@krlmlr
Copy link
Member

krlmlr commented Dec 5, 2020

The tests are failing, is this a false positive or a limitation of RETRY()?

@gaborcsardi
Copy link
Member

@krlmlr Seems like because there is no GH token in the PR.

@krlmlr
Copy link
Member

krlmlr commented Dec 5, 2020

Good catch, will try locally.

@krlmlr
Copy link
Member

krlmlr commented Dec 5, 2020

Can't rerun, this seems to be a special token. Do the tests work for you locally?

@gaborcsardi
Copy link
Member

Can't rerun, this seems to be a special token. Do the tests work for you locally?

Yes.

@krlmlr
Copy link
Member

krlmlr commented Dec 5, 2020

I like the approach. Of course we could do better by reviewing the headers. Merging this will ease the pain of failing GHA tests due to rate limits.

@krlmlr
Copy link
Member

krlmlr commented Dec 5, 2020

Maybe we should use RETRY(quiet = FALSE) or RETRY(quiet = .progress) ?

@gaborcsardi
Copy link
Member

This feels like a big change for me, and I think it would be better to make it optional and opt-in.

@krlmlr
Copy link
Member

krlmlr commented Dec 5, 2020

I'll test-drive it so that we can gain more experience here.

Opt-in won't fix the problems right away, we'd need to change all packages that use it to opt in.

@gaborcsardi
Copy link
Member

What are the problems that this would fix right away?

@krlmlr
Copy link
Member

krlmlr commented Dec 5, 2020

I'm hoping that the functions in remotes that access the GitHub API will wait when the rate limit is exceeded, when they would otherwise fail.

@gaborcsardi
Copy link
Member

I'm hoping that the functions in remotes that access the GitHub API will wait when the rate limit is exceeded, when they would otherwise fail.

remotes does not use gh for anything.

@jameslamb
Copy link
Author

This PR has been open for 20+ months, and hasn't received a new comment in over a year. I'm going to close it and leave it to maintainers to make this change separately if you want.

@jameslamb jameslamb closed this Jan 29, 2022
@jameslamb jameslamb deleted the retry-logic branch January 29, 2022 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants