Skip to content

fetch with retry for mergeUI #11065

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

RayBB
Copy link
Collaborator

@RayBB RayBB commented Jul 23, 2025

@github-project-automation github-project-automation bot moved this to Waiting Review/Merge from Staff in Ray's Project Jul 23, 2025
@RayBB RayBB requested a review from cdrini July 23, 2025 04:26
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Nice this looks like a good approach! A few fixes/comments.

// This block catches network errors (e.g., DNS, connection refused) and the server errors we threw above.
}
const backoff = Math.pow(2, attempt) * initialDelay;
const jitter = Math.random() * backoff;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make more sense to have the jitter be based only on the initialDelay without the exponential? That should avoid it having a range up to 2x the backoff.

// TODO: this line is just for testing locally, remove before merging
CONFIGS.OL_BASE_BOOKS = 'https://openlibrary.org'

export async function fetchWithRetry(resource, options = {}, maxRetries = 5, initialDelay = 5000) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you experiment with 1500 or 2000 as the default? Does that work?

Suggested change
export async function fetchWithRetry(resource, options = {}, maxRetries = 5, initialDelay = 5000) {
export async function fetchWithRetry(resource, options = {}, maxRetries = 5, initialDelay = 1500) {

@RayBB RayBB marked this pull request as ready for review July 25, 2025 06:28
@RayBB RayBB requested a review from cdrini July 25, 2025 06:28
@RayBB
Copy link
Collaborator Author

RayBB commented Jul 25, 2025

@cdrini this one has incorporated all your feedback and is ready for another review. Seems to work quite well with the little check on the last 429 seen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Waiting Review/Merge from Staff
Development

Successfully merging this pull request may close these issues.

Impossible to merge works - web client should respect rate limits
2 participants