fix(api): eliminate N×Coolify calls on site list and startup sync#116
Open
rdemeritt wants to merge 1 commit into
Open
fix(api): eliminate N×Coolify calls on site list and startup sync#116rdemeritt wants to merge 1 commit into
rdemeritt wants to merge 1 commit into
Conversation
GET /api/sites was firing listDeployments() for every app (N extra calls per request). Startup sync was calling getApplication() per dockercompose app redundantly — listApplications() already returns the same data. Combined these hit Coolify's 200 req/min rate limit during development restarts, causing 429 → 500 on the sites page. Fix: pass [] for deployments on list view (detail endpoint unchanged); remove redundant getApplication() from startup sync.
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
GET /api/siteswas callinglistDeployments()for every app (N extra Coolify calls per request). The startup sync was callinggetApplication()per dockercompose app redundantly —listApplications()already returns the same data. Combined, these exceeded Coolify's 200 req/min rate limit during dev restarts, causing 429 → 500/502 on the sites page.Root cause timeline
This worked fine for months because the rate limit was never hit under normal usage (infrequent restarts, few sites). Today's rapid successive API rebuilds (PRs #113–#115) combined with user activity tipped past the threshold for the first time.
Changes
api/src/routes/sites.ts—GET /api/sitesdropslistDeployments()per app; passes[]for deployments on the list view.GET /api/sites/:slug(single-site detail) is unchanged and still returns full deployment history.api/src/index.ts— startup sync dropsgetApplication()per dockercompose app; uses the app object fromlistApplications()directly.provisionTraefikRouteForComposealready handles missingdocker_compose_rawinternally via its own polling loop.API contract impact
GET /api/sites—deploysfield is now always[]. Consumers needing deployment history must useGET /api/sites/:slug.QA results (7/7 pass)
deploys: []on list, full history on detail ✅