-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry failed token price updates #3655
Conversation
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. Ignoring: Next stepsTake a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with |
b88b8bd
to
c428689
Compare
@SocketSecurity ignore [email protected] This package shouldn't have shell access, but it's only being used in a test file. I have made an issue requesting that they be removed here: connor4312/cockatiel#84 |
c428689
to
166bc0c
Compare
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`. Closes #2084
166bc0c
to
adbf103
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job with the tests — I appreciate the comments. I'm surprised that we don't have to account for the jitter in ExponentialBackoff when we mock timers, but I'm not complaining. I'm also curious whether it makes sense to move the retry functionality out of this file in the future so that an arbitrary service object can be customized with retry functionality, but we can cross that bridge when we get there.
Two comments, but both are non-blocking.
packages/assets-controllers/src/token-prices-service/codefi-v2.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Elliot Winkler <[email protected]>
That's why I used the max delay - to not have to worry about the random jitter affecting the timing. Even with the exponential backoff and random jitter, it should always be delayed by no greater than the max delay. Of course that 30 second wait is way way longer than it typically waits between retries, but in an environment with fake timers that doesn't really matter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
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
CodefiTokenPricesServiceV2
will retry if the token price update failstokenPriceRetryAttempts
- 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