Skip to content
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

Merged
merged 6 commits into from
May 23, 2023
Merged

Conversation

julien-devatom
Copy link
Contributor

Description of change

  • add a timeout per provider and a retry policy for each provider

Closes: #7

Pull-Request Checklist

  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions outlined in the conventional commit spec

oumar-fall
oumar-fall previously approved these changes May 19, 2023
Copy link
Collaborator

@oumar-fall oumar-fall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment

src/FallbackProvider/FallbackProvider.ts Outdated Show resolved Hide resolved
src/FallbackProvider/FallbackProvider.ts Outdated Show resolved Hide resolved
} catch (e) {
if (retries++ < (maxRetries ?? DEFAULT_RETRIES)) {
// Wait for a random time before retrying.
const delay = Math.ceil(Math.random() * (retryDelay ?? RETRY_DELAY));
Copy link
Contributor

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.

Copy link
Contributor Author

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

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).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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

Copy link
Contributor

@ghivert ghivert left a 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.

ghivert

This comment was marked as duplicate.

@julien-devatom julien-devatom merged commit af61af7 into main May 23, 2023
7 checks passed
@julien-devatom julien-devatom deleted the feat/implement-retry-logic branch May 23, 2023 10:17
@github-actions
Copy link

🎉 This PR is included in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a retry policy
4 participants