Skip to content

fix: retry transient HTTP failures - #226

Open
victor0602 wants to merge 1 commit into
mainfrom
codex/http-retries
Open

fix: retry transient HTTP failures#226
victor0602 wants to merge 1 commit into
mainfrom
codex/http-retries

Conversation

@victor0602

@victor0602 victor0602 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • Add centralized, bounded retries for transient network failures and HTTP 408, 429, 500, 502, 503, and 504 responses.
  • Use exponential backoff with jitter, honor Retry-After, and cap delays.
  • Recreate per-attempt timeout signals and safely replay JSON and FormData request bodies.
  • Keep permanent HTTP errors fail-fast.

Why

The shared HTTP layer previously made a single attempt, exposing every command and SDK operation to temporary rate limits, service errors, and network instability.

Impact

Transient failures can recover automatically while retry counts and delays remain bounded.

Checks

  • bun test — 469 passed
  • bun run typecheck
  • bun run lint — no errors; one pre-existing test warning
  • git diff --check

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@victor0602
victor0602 marked this pull request as ready for review August 5, 2026 12:11

@NianJiuZst NianJiuZst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not recommend merging this revision yet.

[P1] Do not retry every request method by default. This shared loop replays all POSTs, and the CLI uses it for generation jobs, uploads, and other state-changing operations. If the server commits a paid job but the connection drops (or it returns a retryable 5xx before the client receives confirmation), this sends the POST again and can create duplicate work or charges. A minimal fetch stub that committed before throwing produced sideEffects: 2. Restrict automatic retries to safe/idempotent methods, or require an explicit per-request opt-in backed by a provider idempotency key.

Local verification: typecheck, lint (one pre-existing warning), build, 24 focused tests, and the full suite (469/469) passed. The green replay tests currently encode the unsafe behavior rather than protecting against it.

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.

2 participants