Skip to content

feat(keeper): add retry logic with exponential backoff for failed charges - #8

Open
VedantMadane wants to merge 1 commit into
Demilade10:mainfrom
VedantMadane:feat/issue-7-keeper-retry
Open

feat(keeper): add retry logic with exponential backoff for failed charges#8
VedantMadane wants to merge 1 commit into
Demilade10:mainfrom
VedantMadane:feat/issue-7-keeper-retry

Conversation

@VedantMadane

Copy link
Copy Markdown

Summary

Add retry logic to the keeper so transient failures do not silently drop a scheduled charge.

Changes

  • keeper/retry.js (new) — exponential backoff helper with permanent vs retryable classification
  • keeper/keeper.js — charge path uses withRetry (max 3 attempts); before retrying, confirms via getTransaction that a prior submission did not already succeed (no double-charge)
  • keeper/simulate_retry.js — local simulation of transient recovery, permanent skip, and already-SUCCESS guard

Behaviour

Failure Action
Network/RPC timeout, 5xx, NOT_CONFIRMED Retry with backoff (cap 3)
Unauthorized, insufficient allowance, cancelled, not due Log and skip (no retry)
Prior tx hash already SUCCESS Do not retry

Simulated run log

=== simulate transient RPC failure then success ===
charge(sub=0): attempt 1/3 failed: network timeout talking to RPC — will retry
charge(sub=0): backing off 10ms before attempt 2
charge(sub=0): attempt 2/3 failed: network timeout talking to RPC — will retry
charge(sub=0): backing off 21ms before attempt 3
charge(sub=0): succeeded on attempt 3/3
result: { status: 'SUCCESS', hash: 'SIMULATED_HASH' }

=== simulate permanent insufficient allowance ===
permanent (attempt 1): HostError: Error(Contract, #2) insufficient allowance
charge(sub=1): attempt 1/3 failed: ... — giving up

=== simulate prior tx already SUCCESS (no double-charge) ===
prior tx ALREADY_LANDED already SUCCESS — not retrying
gave up after sends= 1

Run: node keeper/simulate_retry.js

Fixes #7

…rges

Distinguish transient RPC/network failures from permanent contract errors,
retry with exponential backoff (max 3), and confirm via transaction status
lookup that a charge did not already succeed before retrying.

Fixes Demilade10#7

Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
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.

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

1 participant