Repository navigation
feat: realtime connection health and data freshness (closes #43) - #173
Merged
Marvell69 merged 2 commits intoOct 19, 2026
Merged
Conversation
Adds a shared health monitor (Stellar RPC + backend API + realtime socket), a navbar health indicator, a shared SourceTag with ledger id and read age, on-chain market reads stamped with the ledger they came from, and a staleness guard before trades are signed.
|
@Yilkash is attempting to deploy a commit to the Marvel's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@dimka90 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Issue 43: Show realtime connection health and data freshness across the app
Problem: The
/marketsfilter bar's pulsing green dot is decoration — it pulses whether the socket is connected, the Stellar RPC is down, or the backend has been asleep.SourceTagis defined twice inline, carries no ledger or timestamp, and every on-chain read discardslatestLedger, so React Query's wall-clockdataUpdatedAtis the only freshness signal. The buy button never refuses a stale read, and nothing in the navbar reports the real state of the three data paths.Resolution:
lib/stellar/health.ts):probeRpc(ok/degraded/down, latest ledger + age,degradedwhen the ledger has not advanced for >30 s) andprobeBackend(GET /health, outside/api/v1, 8 s timeout, envelope-checked).createHealthMonitorruns both on an interval with per-probe exponential backoff, resets on success, pauses whiledocument.hidden, and probes immediately onvisibilitychange→visible andonline.lib/health/HealthProvider.tsx, mounted inapp/layout.tsxinsideWalletProvider): combines the two probes with the realtime socket state (useRealtimeStatus()added tolib/realtime/RealtimeProvider.tsx, observingconnect/disconnect/connect_error/reconnect_attempt) and exposesuseHealth()→{ socket, rpc, backend, overall, retry }, rendering a deterministiccheckingstate on the server so hydration matches.components/layout/HealthIndicator.tsx): button left of the bell with a coloured dot and a text label (Live / Degraded / Offline / Checking),aria-expanded, Escape-closable popover listing Socket, Stellar RPC and Backend API with ledger and last-checked time plus "Retry now".SourceTag(components/ui/source-tag.tsx): one implementation replacing both inline copies inapp/markets/page.tsxandapp/markets/quick-view/page.tsx; showsledger N · 12 s agoin the tooltip and to screen readers, re-renders at most every 5 s through a single shared ticker (lib/health/useTicker.ts), and switches to astalevariant paststaleAfterSec(default 60).OnChainMarketViewnow carriesledgerfromsimulatedWithLedger, so chain-sourced tags say which ledger they came from rather than only client wall-clock time./marketsFilterBaris gone;NETWORK_LABELrenders as plain text.handleBuyrefuses to build a transaction whilerpc.status === "down", and refreshes the market read before signing when it is older than 60 s.Verification:
npm run typecheckclean ·npm run lint0 errors (35 pre-existing warnings) ·npm test194 passed / 26 files, including the 13 new cases inlib/stellar/__tests__/health.test.ts(probe ok / degraded / down, backend envelope + timeout, monitor backoff + reset, hidden-tab pause + visibility probe,isStale).Excluded from this slice (documented, not silently dropped): the copy-trade staleness guard, the optional
useChainFreshness(queryKey)accessor, and thedocs/architecture.md/docs/manual-test.mdsections called for in the issue's step 9. Health probing is status-only — it does not back data queries (issue #87) and adds no offline cache (#123) or RPC failover (#120).Closes #43
Closes #44
Closes #45
Closes #46