fix: add periodic health polling to prevent stale sidebar status dots#148
Merged
Mananwebdev160408 merged 1 commit intoJul 4, 2026
Conversation
checkConnectionHealth was defined but never called after init(). Add a 30s setInterval useEffect so health status updates automatically without requiring a page refresh. Fixes Mananwebdev160408#144
Contributor
Author
|
"Hi @Mananwebdev160408, just checking in on PR #148 when you get a chance. Happy to make any changes if needed!" |
Contributor
Author
|
in the lables why gssoc approved it not showing i need it for my point please check it |
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
Fixes #144
The
checkConnectionHealthfunction inApp.tsxwas defined as auseCallbackbut had no caller after the initialinit()function completed. This meant health status dots in the sidebar were only ever checked once — at page load — and became permanently stale. If a database went down after load, the UI would still show it as healthy with no way to detect the change short of a full page refresh.Root Cause
checkConnectionHealthwas defined but never wired to any recurring trigger — nosetInterval, no pollinguseEffect. It was essentially dead code afterinit()finished.Fix
Added a
useEffectthat runs asetIntervalevery 30 seconds to re-ping/api/health?dbId=...for each configured connection and updateisAliveon the connections state, which flows directly into the sidebar health dots.Key Design Decisions
[connections, isDockerMode], not[]— the interval callback closes overconnections. Using[]would cause a stale closure where the interval always polls with the empty array from the first render (beforeinit()finishes). Withconnectionsin the deps, React recreates the interval each time the list updates, so it always has current data./api/healthis a database-mode endpoint; no-op in Docker mode.connections.length === 0— avoids firing beforeinit()has populated the connection list.clearInterval— the effect returns a cleanup function so the interval is properly torn down on unmount, no memory leaks.Files Changed
frontend/src/App.tsx— added 25 lines (oneuseEffectblock)Testing
DATABASE_URL