Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR adds the retrying of requests to
NVDApi
and the inheriting classes.Why
NVD is super unstable lately, so it's nearly impossible to retrieve a large response, because one of the HTTP requests will very likely fail. This caused vt-cve-library to be broken right now and cve-feeder to occasionally fail.
The current behavior on
main
is that the caller needs to handle those errors. However, the caller doesn't know which request (the offset of the paginated response) exactly failed, so send a new request starting from failed requests offset.One option would be to somehow pass this offset to the caller, however I opted for the approach to handle retries directly inside Pontos, just like rate-limiting also is for a more out-of-the-box developer experience.
This implementation is backwards-compatible and assumes one attempt, if not specified otherwise.
If
attempts
is greater than1
and there is a server-side (HTTP 5xx) error in the response, the request will be retried after a delay of 2 seconds, exponentially backing off.In my tests for vt-cve-library I was finally able to request data from NVD again, which failed after a few minutes before this change.
References
Checklist