plugin-retry.js
plugin-retry.js copied to clipboard
[FEAT]: possibility to override errorRequest
Describe the need
doNotRetry only supports checking on status code. This is not enough in some cases.
For example, I have a flow where I create a new repository and then make some additional calls, setting team permissions adding topics etc. Sometimes those follow-up calls fails with 422 and an error like this:
{
message: 'Validation Failed',
errors: [
{
resource: 'TeamRepository',
code: 'unprocessable',
field: 'data',
message: 'This repository is locked and cannot be modified.'
}
],
documentation_url: 'https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions'
}
While it does not make sense to always retry 422, it would perhaps make sense to do it if code is 422 and message contains this "is locked". In some cases, not all perhaps. Because repos could really be locked too. But in my case I know it wont be. If I would be able to specify my custom logic, I could tailor it for my needs. Atm I instead opt to clone all code, just to change that logic.
Regarding this particular case, GitHub support have replied that this is expected (https://support.github.com/ticket/personal/0/2465057 if you has access to internal tickets):
It can take time for replication of data, and we lock the repositories during creation and changes to permissions, as you've noted. It really depends on the current load. We recommend retrying with exponential backoff in such situations.
SDK Version
No response
API Version
No response
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct