Skip to content

feat: retry 502/503/504 with jittered backoff (SHA-1994)#1

Merged
Mlaz-code merged 1 commit into
mainfrom
sha-1994-sdk-retry
Apr 19, 2026
Merged

feat: retry 502/503/504 with jittered backoff (SHA-1994)#1
Mlaz-code merged 1 commit into
mainfrom
sha-1994-sdk-retry

Conversation

@Mlaz-code
Copy link
Copy Markdown
Contributor

Summary

  • HttpClient now retries transient upstream failures (502/503/504 or fetch errors) up to 3 times
  • Full-jitter exponential backoff: 500ms base → 4s cap
  • Timeouts (AbortError) do not retry — they fail fast as before
  • Also DRYs up get() and post() onto a single request() path

Context

Filed against SHA-1994. During the SHA-1929 deploy on 2026-04-19 15:53 UTC, sharp-api-go was restarted via systemctl to pick up new ClickHouse env vars — this caused 74 × 5xx over ~3s for live customer requests. The server side is being fixed with a dedicated config-reload helper (sharp-api-go repo), and the SDKs add defense-in-depth retry so SDK users don't see the gap at all.

Test plan

  • 60 existing tests pass locally (npm test)
  • tsc --noEmit passes
  • Verify retry actually kicks in via a dummy 503 mock once CI runs

🤖 Generated with Claude Code

HttpClient now retries up to 3 times on transient upstream failures
(502/503/504 or fetch errors) with full-jitter exponential backoff
(500ms base → 4s cap). Shields SDK users from the ~3s cold-start gap
when sharp-api-go restarts during deploys. Also DRYs up get/post onto
a single request() path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Mlaz-code Mlaz-code merged commit 02fbfb3 into main Apr 19, 2026
@Mlaz-code Mlaz-code deleted the sha-1994-sdk-retry branch April 19, 2026 16:58
Mlaz-code added a commit that referenced this pull request May 7, 2026
HttpClient now retries up to 3 times on transient upstream failures
(502/503/504 or fetch errors) with full-jitter exponential backoff
(500ms base → 4s cap). Shields SDK users from the ~3s cold-start gap
when the SharpAPI server restarts during deploys. Also DRYs up get/post onto
a single request() path.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.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.

1 participant