Skip to content

Add built-in retry mechanism with exponential backoff for subgraph queries #149

Description

@Lakes41

Difficulty: Intermediate
Type: feature, resilience

Background

The SDK relies on The Graph (subgraphs) to fetch indexed on-chain data. Currently, if a query fails due to a temporary gateway timeout, the SDK instantly throws an error.

Problem

Network hiccups or subgraph syncing delays cause intermittent UI failures for downstream applications. Developers are forced to implement their own retry wrappers.

Expected outcome

The SDK's data-fetching module includes an automated retry mechanism utilizing exponential backoff to handle transient network errors gracefully.

Suggested implementation

  1. Modify the internal fetch client to accept retries and retryDelay configuration parameters.
  2. Implement a loop/recursion that captures 50x HTTP errors or network timeouts and retries the request.
  3. Wait exponentially longer between subsequent retries (e.g., 500ms, 1s, 2s).

Acceptance criteria

  • Failed queries automatically retry up to 3 times by default.
  • 400 Bad Request errors are not retried.
  • Unit tests mock network failures and verify the backoff timing.

Likely affected files/directories

  • src/api/graphqlClient.ts

Requirements

  • The retry logic must be configurable (allow developers to opt-out by setting retries to 0).

Metadata

Metadata

Assignees

Labels

GrantFox OSSRelated to GrantFox Open Source Software initiativesMaybe RewardedPotential for a reward based on contributionOfficial Campaign | FWC26Period after the official FIFA World Cup 2026 campaignfeatureNew feature or requestintermediateGood for intermediate level contributorsresilienceSystem resilience and error handling

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions