Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retry failed token price updates (#3655)
## Explanation The `token-prices-service` will now retry token price updates if they fail. The retry strategy is designed to let the API recover if it is experiencing high traffic volumes. The service now requires state in order to hold onto the retry policy. It has been converted to a class for that reason. This required no changes to the abstract price service type or to the `TokenRatesController`. ## References Closes #2084 ## Changelog ### `@metamask/assets-controllers` - Changed: The `CodefiTokenPricesServiceV2` will retry if the token price update fails - We retry each request up to 3 times using a randomized exponential backoff strategy - If the token price update still fails 5 times consecutively (including the 3 retries each attempt, so 15 consecutive failures total), we stop trying for 30 minutes before we try again. - The service has been converted from a collection of functions to a class. The newly added constructor has these options: * `tokenPriceRetryAttempts` - Number of retry attempts for each token rate update. * `tokenPriceMaximumConsecutiveFailures` - The maximum number of consecutive failures allowed before breaking the circuit and pausing further updates. * `tokenPriceCircuitBreakDuration` - The amount of time to wait when the circuit breaks from too many consecutive failures. ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate --------- Co-authored-by: Elliot Winkler <[email protected]>
- Loading branch information