Skip to content

feat(indexer): exponential backoff retry on event_type_filter RPC calls - #307

Merged
godamongstmen897 merged 2 commits into
Goldii-locks:mainfrom
eliassmthl-collab:#276-Build-exponential-backoff-retry-strategies-on-event_type_filter
Aug 30, 2026
Merged

feat(indexer): exponential backoff retry on event_type_filter RPC calls#307
godamongstmen897 merged 2 commits into
Goldii-locks:mainfrom
eliassmthl-collab:#276-Build-exponential-backoff-retry-strategies-on-event_type_filter

Conversation

@eliassmthl-collab

Copy link
Copy Markdown
Contributor

Introduce src/indexer/event_type_filter.ts as a dedicated module that wraps Soroban RPC getEvents with exponential-backoff retry logic for transient connection failures.

Changes:

  • Add EVENT_TYPES constant (single source of truth, removed from poller)
  • Add isConnectionError() to classify retryable network errors (ECONNREFUSED, ETIMEDOUT, ECONNRESET, fetch failed, socket hang up, etc.)
  • Add nextBackoff() helper: doubles delay each attempt, caps at 300 000 ms
  • Add fetchEventsWithRetry(): retries up to MAX_ATTEMPTS (5) on connection errors with 1 s initial backoff doubling each failure; non-connection errors propagate immediately without retrying; sleep is injectable for deterministic testing
  • Update poller.ts to delegate getEvents to fetchEventsWithRetry so every poll cycle recovers gracefully from RPC connection dropouts
  • Add tests/event-type-filter.test.ts with 53 tests covering:
    • EVENT_TYPES content
    • isConnectionError classification (14 error patterns)
    • nextBackoff doubling and cap behaviour
    • Retry call counts match maxAttempts exactly on total failure
    • Sleep delays grow strictly: [1000, 2000, 4000, 8000] for 5 attempts
    • Immediate abort on non-connection errors
    • Mixed connection/non-connection error sequences

All 730 existing tests continue to pass (42 suites).

Closes #276

Introduce src/indexer/event_type_filter.ts as a dedicated module that
wraps Soroban RPC getEvents with exponential-backoff retry logic for
transient connection failures.

Changes:
- Add EVENT_TYPES constant (single source of truth, removed from poller)
- Add isConnectionError() to classify retryable network errors
  (ECONNREFUSED, ETIMEDOUT, ECONNRESET, fetch failed, socket hang up, etc.)
- Add nextBackoff() helper: doubles delay each attempt, caps at 300 000 ms
- Add fetchEventsWithRetry(): retries up to MAX_ATTEMPTS (5) on connection
  errors with 1 s initial backoff doubling each failure; non-connection
  errors propagate immediately without retrying; sleep is injectable for
  deterministic testing
- Update poller.ts to delegate getEvents to fetchEventsWithRetry so every
  poll cycle recovers gracefully from RPC connection dropouts
- Add __tests__/event-type-filter.test.ts with 53 tests covering:
  - EVENT_TYPES content
  - isConnectionError classification (14 error patterns)
  - nextBackoff doubling and cap behaviour
  - Retry call counts match maxAttempts exactly on total failure
  - Sleep delays grow strictly: [1000, 2000, 4000, 8000] for 5 attempts
  - Immediate abort on non-connection errors
  - Mixed connection/non-connection error sequences

All 730 existing tests continue to pass (42 suites).

Closes Goldii-locks#276
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@eliassmthl-collab Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@godamongstmen897

Copy link
Copy Markdown
Contributor

@eliassmthl-collab fix failed CI check and resolve conflict

@godamongstmen897
godamongstmen897 merged commit 9a936ea into Goldii-locks:main Aug 30, 2026
1 check failed
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.

Build exponential backoff retry strategies on event_type_filter

2 participants