feat(stellar): implement circuit breaker for all Stellar RPC calls#868
Merged
Anuoluwapo25 merged 4 commits intoApr 29, 2026
Merged
Conversation
- Add CircuitBreaker class with CLOSED/OPEN/HALF_OPEN state machine - Open circuit after N consecutive failures (default: 5, env: STELLAR_CB_FAILURE_THRESHOLD) - Transition to HALF_OPEN after reset timeout (default: 30s, env: STELLAR_CB_RESET_TIMEOUT_MS) - Close circuit on first successful probe in HALF_OPEN state - Log all state transitions (CLOSED -> OPEN -> HALF_OPEN -> CLOSED) - Wrap all 12 Stellar RPC functions with stellarRpcCircuitBreaker.call(): callVerifyMilestone, emitRejectionEvent, callMintScholarNFT, isEnrolled, submitScholarshipProposal, castVote, cancelProposal, reclaimInactiveEscrow, getLearnTokenBalance, getGovernanceTokenBalance, getGovernanceVotingPower, getGovernanceDelegation - Expose circuit state (state, consecutiveFailures, openedAt) in GET /api/health under the 'stellarRpc' key Closes #<ISSUE_NUMBER>
|
@Obiajulu-gif 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! 🚀 |
Contributor
|
kindly fix conflicts.....And i noticed you don't give people issues on your repo...nice |
Anuoluwapo25
added a commit
that referenced
this pull request
May 26, 2026
…aker feat(stellar): implement circuit breaker for all Stellar RPC calls
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
This pr closes #611
All Stellar RPC calls (contract reads/writes, Horizon queries) were made without any circuit breaker. If the Soroban RPC endpoint degraded or became unresponsive, the server would continue making slow, blocking calls indefinitely — tying up resources and propagating failures to all dependents.
Solution
A custom
CircuitBreakerclass implementing the standard three-state pattern:CircuitOpenErrorState transitions are logged on every change:
Changes
server/src/services/stellar-contract.service.tsCircuitStatetype,CircuitBreakerclass,CircuitOpenErrorclassstellarRpcCircuitBreakerinstance (configurable via env vars)stellarRpcCircuitBreaker.call()server/src/routes/health.routes.tsstellarRpcCircuitBreakerstellarRpcfield toGET /api/healthresponse:{ "stellarRpc": { "state": "CLOSED", "consecutiveFailures": 0, "openedAt": null } }Configuration
STELLAR_CB_FAILURE_THRESHOLD5STELLAR_CB_RESET_TIMEOUT_MS30000