perf(dev-server): fetch flags concurrently on startup#738
Closed
davidbrackbill wants to merge 1 commit into
Closed
perf(dev-server): fetch flags concurrently on startup#738davidbrackbill wants to merge 1 commit into
davidbrackbill wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f764bb3. Configure here.
The dev server paginated the flag list serially (following next-links at 100/page), taking up to ~50s in CI on large projects. Fetch pages concurrently instead: pull page 0, and while pages come back full, fetch the rest in bounded concurrent batches until a short page ends the list. - New internal.FetchPagesConcurrently paginator (with tests), replacing the serial GetPaginatedItems. It never trusts the API's optional total count (which reads back as 0 when absent and would truncate large projects) - a short page is the only end-of-list signal. - Retry429s: guard against a nil response before dereferencing StatusCode, so a transport-level failure returns an error instead of panicking. Api.GetAllFlags keeps its signature, so nothing downstream changes. Claude <claude@anthropic.com>
f764bb3 to
e6e9ddc
Compare
Contributor
Author
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.

Problem
The dev server paginates the flag list serially (following
nextlinks at 100/page) during startup, taking up to ~50s in CI on large projects (e.g. Catamorphic) before the health check passes.Fix
Fetch the pages concurrently instead: pull page 0, and while pages come back full, fetch the rest in bounded concurrent batches until a short page marks the end of the list.
internal.FetchPagesConcurrentlypaginator (unit-tested), replacing the serialGetPaginatedItems. It never trusts the API's optional total count — that field reads back as0when absent and would silently truncate large projects, so a short page is the only end-of-list signal.Retry429snow guards against a nil*http.Responsebefore dereferencingStatusCode, so a transport-level failure (DNS, connection refused) returns an error instead of panicking.Api.GetAllFlagskeeps its signature, so nothing downstream changes — this is a contained, behavior-preserving speedup. Variation names are still fully resolved before the server reports healthy (just fetched concurrently); the health-check contract is unchanged.Scope
This is the base of a two-PR split. A follow-up adds an opt-in
--stream-flag-startupmode (values off the SDK stream + background name fill) for ~1s health checks; that machinery is reviewed separately, on top of this.Outcome
Claude claude@anthropic.com
Note
Medium Risk
Changes startup data-fetch behavior (ordering preserved, but more parallel API load and different pagination semantics) plus error-handling in shared
Retry429s; contained to dev-server adapters with unit tests.Overview
Replaces serial LaunchDarkly flag list pagination (following
nextlinks) with bounded concurrent offset paging so dev-server startup on large projects is much faster whileGetAllFlagsstays the same for callers.getFlagsnow uses newFetchPagesConcurrently(page size 100, concurrency 6): load page 0, then pull further pages in parallel batches until a short page ends the list—explicitly not using optional API total counts that can read as 0 and truncate results. The oldGetPaginatedItems/parseHrefpath is removed.Retry429sonly returns early when*http.Responseis nil (transport failures), so 429s that arrive with both error and response still retry; tests cover nil-response and 429+error cases.Reviewed by Cursor Bugbot for commit e6e9ddc. Bugbot is set up for automated code reviews on this repo. Configure here.