plugin-retry.js
plugin-retry.js copied to clipboard
Feature Request: A doRetry parameter
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.
Let me know if the team is interested in this feature, I would be willing to create a PR for this feature
did you try setting retry on the specific request? We have this documented in our docs
"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?
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)
So there is currently no way to retry on a 202 response using this plugin?
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.
Unfortunately, I do not have the time for this on such a short time frame. Good luck on your future endeavors :)