Retry rate-limited flag requests - #253
Open
austinbutler wants to merge 1 commit into
Open
austinbutler wants to merge 1 commit into
austinbutler wants to merge 1 commit into
Conversation
austinbutler
marked this pull request as ready for review
September 29, 2026 21:21
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following my PR #251, I noticed a higher rate of 429s from LaunchDarkly's API in our CI. Makes sense, pagination means more requests.
So this PR adds retries. It's based on your own documentation for rate limiting.
I've run it in our CI for a few weeks, resulting in thousands of runs, and it handles 429s properly and the overall failure rate remains comparable to before the migration to pagination.
Please feel free to do what you want with this PR, for example if lots of changes are needed and you want to do it yourself, take whatever you want from this PR. I only want to raise the issue and ensure it gets addressed somehow.
Note
Overview
Replaces the paginated LaunchDarkly flag list client with a context-aware
flagFetcherbuilt ongo-retryablehttp.GetAllFlagsnow acceptscontext.Context(wired frommain), applies a 120s inventory timeout, and only retries HTTP 429 responses—usingRetry-After, reset headers, and remaining-quota headers per LD’s rate-limiting docs, with exponential backoff when hints are missing.Between pages it can pause proactively when responses show exhausted quota (including before switching active → archived). Failures return structured
flagFetchErrorreasons (canceled, rate-limit deadline/exhausted, decode, etc.), avoid partial flag lists on mid-inventory errors, and surface cancellation/timeouts while reading response bodies.LD_FLAG_FETCHJSON diagnostics log start/summary, rate limits, and intended waits for CI observability.Reviewed by Cursor Bugbot for commit 357fdfd. Bugbot is set up for automated code reviews on this repo. Configure here.