Conversation
…ol#630) Adds a circuit breaker that tracks consecutive failures per RPC URL. Consumers can call getCircuitState(rpcUrl) to check if the endpoint is 'closed' (healthy), 'open' (degraded), or 'half-open' (probing) without catching thrown errors. - src/rpc-circuit-state.ts: getCircuitState, recordSuccess, recordFailure, resetCircuit, getAllCircuitStates - createRpcServer proxy now records success/failure on each RPC call - Exported from the package entry point Addresses conduit-protocol#630
ZacLou
force-pushed
the
feat/circuit-state-630
branch
from
September 5, 2026 14:47
1e26d75 to
e488f1f
Compare
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
Addresses #630
Problem
Consumers had no way to check if an RPC endpoint was degraded without catching the thrown 'circuit open' error. There was no read-only state inspection.
Solution
src/rpc-circuit-state.ts(new)A circuit breaker module with:
getCircuitState(scope)— returns{ state, failureCount, lastFailureAt, lastSuccessAt, cooldownUntil }. State is'closed'(healthy),'open'(degraded, exceeding threshold), or'half-open'(probing after cooldown).recordSuccess(scope)— resets failure count, closes circuitrecordFailure(scope, options?)— increments failure count, opens circuit at threshold (default 5)resetCircuit(scope)— clears all stategetAllCircuitStates()— returns all known circuit states for dashboardssrc/soroban.tsThe
createRpcServerproxy now callsrecordSuccess(rpcUrl)on successful calls andrecordFailure(rpcUrl)when the retry logic exhausts or hits a non-retriable error.src/index.tsExports
getCircuitState,recordSuccess,recordFailure,resetCircuit,getAllCircuitStates,CircuitState,CircuitStatus.Usage
Verification