Skip to content

feat(keeper): add retry logic for failed charge attempts #6

Description

@Demilade10

Description

Add retry logic to the keeper script so transient failures (network errors, ledger congestion, temporary RPC issues) do not silently drop a scheduled charge. Currently a failed charge() call has no retry mechanism.

Requirements and Context

  • keeper.js currently calls charge() on due subscriptions but does not distinguish between a permanent failure (insufficient allowance, cancelled subscription) and a transient one (RPC timeout, network blip)
  • Retries must not double-charge a subscriber - the keeper must confirm a charge did not succeed before retrying
  • Uses @stellar/stellar-sdk for all chain interaction

Suggested Execution

Branch name: feat/keeper-retry-logic

Files to touch:

  • keeper/keeper.js
  • keeper/retry.js (new - retry/backoff helper)

Example commit message: feat(keeper): add retry logic with exponential backoff for failed charges

Test and Commit

  • Distinguishes transient failures (retryable) from permanent failures (not retryable, e.g. Unauthorized, insufficient allowance)
  • Implements exponential backoff with a max retry cap (e.g. 3 attempts)
  • Confirms via transaction status lookup that a charge did not succeed before retrying, to prevent double-charging
  • Logs each retry attempt with reason and outcome
  • Permanent failures are logged and skipped, not retried indefinitely
  • Include a test run log in the PR showing a simulated transient failure recovering on retry

Guidelines

Complexity

High - 200 points

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions