feat: add circuit breaker protection for Horizon SDK calls - #583
Merged
Abdulazeem-code merged 1 commit intoAug 27, 2026
Merged
Conversation
Wrap all Stellar Horizon SDK interactions with opossum circuit breakers to prevent cascading timeouts and crashes when Horizon goes down. - Create src/services/stellarService.js as centralized Horizon wrapper with configurable circuit breakers (threshold, timeout, reset) - Add health-check breaker in horizonListener.js that gates stream sync when Horizon is unreachable - Improve stream resilience: dead streams are removed from active map and auto-reconnect on next poll cycle - Wrap loadAccount, fetchTransaction, fetchPaymentsForTransaction, fetchPaymentsForAccount, and paginated export with breakers - Export paginated results with circuit-breaker-protected next() calls - Detect EOPENBREAKER errors in route handlers and return 503 SERVICE_UNAVAILABLE with graceful error messages - All existing tests pass (370/370) - Add 18 new tests for circuit breaker behavior Closes Abdulazeem-code#499
|
@muffti123 is attempting to deploy a commit to the Abdulazeem's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@muffti123 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.
Summary
This PR wraps all Stellar Horizon SDK interactions with opossum circuit breakers to prevent cascading timeouts and crashes when Horizon goes down.
What changed
New:
src/services/stellarService.jsA centralized Horizon SDK wrapper that provides circuit-breaker-protected versions of all Stellar operations:
loadAccountfetchTransactionfetchPaymentsForTransactionfetchPaymentsForAccountpaginated exportstream health checkUpdated:
horizonListener.jsUpdated: Route handlers (
exportRoutes.js,historyRoutes.js,receiptRoutes.js)EOPENBREAKERerrors from circuit breakers503 SERVICE_UNAVAILABLEwith graceful error messages instead of crashingUpdated:
multisigner-verifier.jsstellarServicewrapperNew:
tests/stellarService.test.jsWhy
When Stellar Horizon experiences downtime or high latency, the SDK calls would hang indefinitely or throw unhandled errors, causing cascading failures across the entire application. Circuit breakers provide:
Testing
Closes #499