plugin-retry.js icon indicating copy to clipboard operation
plugin-retry.js copied to clipboard

Feature Request: A doRetry parameter

Open apaparazzi0329 opened this issue 4 years ago • 7 comments

I was recently implementing a feature in my application that would grab repository statistics from the GET /repos/{owner}/{repo}/contributors endpoint. The problem I ran into was that if statistics have not been compiled before then the endpoint will return a 202 and you will have to retry and poll again to see if the results are ready. It would be nice if this plugin had a "doRetry" parameter that would allow retries for requests that return specified status codes as opposed to only status codes above 400. As it stands, my current implementation is unable to use this plugin and uses a timed loop until a 200 is received. I believe this will be a very useful feature as other endpoints that return a 202 and require retries will be easier to implement.

apaparazzi0329 avatar Sep 20 '21 16:09 apaparazzi0329

Let me know if the team is interested in this feature, I would be willing to create a PR for this feature

apaparazzi0329 avatar Sep 20 '21 16:09 apaparazzi0329

did you try setting retry on the specific request? We have this documented in our docs

image

gr2m avatar Sep 22 '21 00:09 gr2m

"requests will be retried no matter their response code"? So does that mean even if I get a 200 response that the plugin will continue to retry up until the max retries?

apaparazzi0329 avatar Oct 07 '21 15:10 apaparazzi0329

So does that mean even if I get a 200 response that the plugin will continue to retry up until the max retries?

no, only in case of error responses (>=400)

gr2m avatar Oct 07 '21 15:10 gr2m

So there is currently no way to retry on a 202 response using this plugin?

apaparazzi0329 avatar Oct 07 '21 15:10 apaparazzi0329

I don't think so, not at this point. Now I understand your request for the doRetry parameter, sorry it took me so long.

Yes, I agree, a doRetry parameter might be helpful, in some cases we have to do retries only in case of a 404 to account for replication lags of installation access tokens, I think I implemented this functionality manually for that case.

I'd accept a pull request if you are interested in implementing it. However it would need to be done fast, Sunday will be my last day working on Octokit for the foreseeable future, and I don't think anyone else will look at issues / PRs.

gr2m avatar Oct 07 '21 16:10 gr2m

Unfortunately, I do not have the time for this on such a short time frame. Good luck on your future endeavors :)

apaparazzi0329 avatar Oct 08 '21 16:10 apaparazzi0329