Skip to content

feat(chain-watcher): Add RPC health-check and connection management#55

Merged
geminimir merged 1 commit intomainfrom
feature/rpc-health-check
Mar 14, 2026
Merged

feat(chain-watcher): Add RPC health-check and connection management#55
geminimir merged 1 commit intomainfrom
feature/rpc-health-check

Conversation

@geminimir
Copy link
Owner

Summary

Implement health checking for RPC endpoints with periodic eth_blockNumber calls, stale detection, and automatic failover to secondary provider.

Changes

  • Add RpcProvider class with health checking via eth_blockNumber calls every 10 seconds
  • Add RpcHealthManager for managing multiple providers with automatic failover
  • Mark provider unhealthy after 3 consecutive failures or stale block (>30s behind)
  • Failover to secondary RPC provider when primary becomes unhealthy
  • Expose health status via internal metrics (getMetrics())
  • Update shared types with RpcHealthStatus, RpcProviderConfig, and RpcHealthState
  • Add RPC_HEALTH_CHECK constants for configurable intervals and thresholds

How to Test

  1. npm ci
  2. npm run typecheck
  3. npm test --workspace=@stripeonchain/chain-watcher

Tests

  • Tests added/updated (23 new tests)
  • All tests pass (npm test)
  • Lint passes (npm run lint)
  • Type-check passes (npm run typecheck for chain-watcher)
  • Formatting passes (npm run format:check)

Checklist

  • No secrets or credentials committed
  • Migrations run cleanly up and down (npm run migrate:up / npm run migrate:down)
  • Docker Compose starts without errors (docker compose up)

Related Issues

Closes #16

Made with Cursor

- Add RpcProvider class with periodic eth_blockNumber health checks
- Add RpcHealthManager for automatic failover to secondary providers
- Mark provider unhealthy after 3 consecutive failures or stale block
- Expose health status via internal metrics
- Add comprehensive unit tests (23 tests)

Closes #16

Made-with: Cursor
@geminimir geminimir merged commit b7ddb54 into main Mar 14, 2026
1 check passed
@geminimir geminimir deleted the feature/rpc-health-check branch March 14, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add RPC health-check and connection management

1 participant