Skip to content

Implement exponential backoff retry logic #10

Closed

Description

@codebestia

Description

Transient failures (connection resets, 502/503/504 responses) should be automatically retried with exponential backoff and random jitter rather than immediately surfacing to the caller. This makes the SDK resilient to brief network hiccups.

Proposed Steps

  • Implement a _retry_with_backoff(fn, max_retries, base_delay) utility.
  • Retry on: httpx.ConnectError, httpx.TimeoutException, HTTP 502/503/504.
  • Delay formula: min(base_delay * 2**attempt + random.uniform(0, 0.5), 60).
  • Do NOT retry on 4xx client errors (except 429, handled separately).
  • Log each retry attempt at DEBUG level with attempt number and delay.

Acceptance Criteria

  • A request that fails twice then succeeds is returned successfully after the retries.
  • A 400 response is NOT retried — it raises InvalidRequestError immediately.
  • Retries respect max_retries; exceeding it raises NetworkError.
  • The delay between retries grows with each attempt.
  • Retry behaviour is testable by injecting a mock transport.

Activity

  1. G-ELM commented on Jun 25, 2026

    @G-ELM
    Contributor

    I can resolve this task.
    Based on my recent PR in the backend, I have a very good idea of the project and i will be able to implement this properly.

  2. grantfox-oss commented on Jun 25, 2026

    @grantfox-oss

    🦊 GrantFox — @G-ELM has been assigned to this issue as part of the Official Campaign campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #10)
    2. Your PR will be reviewed by the ShadeProtocol maintainers

    Good luck! Track your progress on GrantFox.

  3. grantfox-oss commented on Jun 26, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign campaign!

    @G-ELM's PR #30 was approved and merged by @codebestia.

    🏆 @G-ELM: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (118 total points). Track your full progress on GrantFox.

    👏 Great work, @G-ELM! Keep contributing to ShadeProtocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions