fix: process repositories in batches to prevent partial sync on large orgs#1029
Open
roryharness wants to merge 2 commits into
Conversation
… orgs When an org has many repositories, `eachRepositoryRepos` fires all of them concurrently via `Promise.all`. This exhausts GitHub's API rate limit (5,000 req/hr for app installations) mid-sync, causing the remaining repositories to be silently skipped — leaving them out of sync with the desired config. This change processes repositories in chunks of 10 using `Promise.allSettled`, so: 1. Concurrent API pressure stays well within rate limits 2. A single repo failure no longer aborts the entire sync — errors are logged individually and processing continues
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
SettingsRepository.eachRepositoryReposfetches every repository in the installation and processes them all at once with a singlePromise.all(...)over the full list. On large organizations this has two problems:checkAndProcessRepocalls fire simultaneously, creating heavy API/memory pressure.Promise.allrejects as soon as one repository fails, aborting the entire run. Repositories that hadn't been processed yet are silently skipped, leaving the org partially synced.Fix
CONCURRENCY = 10) instead of all at once, bounding concurrency and API pressure.Promise.allSettledper batch so a single repository's failure no longer aborts the whole sync. Failed repositories are logged vialog.errorand processing continues.This makes full-org syncs resilient: one bad repository no longer prevents the rest of the org from being synced.
Additional change
COPY full-sync.js /opt/safe-settings/to theDockerfileso the full-sync entrypoint is present in the built image (it was previously omitted).Behavior / compatibility