-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feat/implement retry logic #8
Conversation
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.
One comment
} catch (e) { | ||
if (retries++ < (maxRetries ?? DEFAULT_RETRIES)) { | ||
// Wait for a random time before retrying. | ||
const delay = Math.ceil(Math.random() * (retryDelay ?? RETRY_DELAY)); |
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.
I don't get why waiting for a random time instead of just the max time (retryDelay ?? RETRY_DELAY
). It makes things a little bit non-deterministic.
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.
this is to resolve throughput issues on a node. If you retry x queries where the issue is that these x issues are sent at the same time, using a random time is the only way to solve that.
NB: the delay of an http query is already non deterministic
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.
I don't see how this solves the node throughput issue. It seems to be worsening it by globally shortening the time between each failed request (compared to waiting the max time).
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.
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.
The implementation corresponds to the Option 3 simple retries povided by Alchemy
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.
retries++
is a bad practice to my eyes.
🎉 This PR is included in version 1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description of change
Closes: #7
Pull-Request Checklist
Fixes #0000