Skip to content

Build SDK fallback chain #142

@Kingsman-99

Description

@Kingsman-99

Label: complexity: high
Points: 200

Description

The current failover logic tries endpoints in a fixed order without logging why each failed. This issue adds a FallbackChain that tries a sequence of RPC endpoints, logs each failure with reason, and returns the first successful result.

Technical Context

Involves a new src/fallbackChain.ts. FallbackChain accepts an ordered array of RPC URLs. For each request, try URLs in order. On failure, log { url, error, attemptMs } and try next. On all failures, throw a FallbackExhaustedError containing all attempt logs. Export FallbackChain and FallbackExhaustedError.

Acceptance Criteria

  • FallbackChain class exported from src/index.ts
  • Tries endpoints in provided order
  • Each failure logged with URL, error message, and duration
  • FallbackExhaustedError thrown with all attempt logs when all fail
  • Test with 2 failing URLs verifies error contains both attempt logs
  • All existing tests pass
  • TypeScript strict mode — zero any types

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions