fix: retry transient HTTP failures - #226
Conversation
NianJiuZst
left a comment
There was a problem hiding this comment.
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.
What changed
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 passedbun run typecheckbun run lint— no errors; one pre-existing test warninggit diff --checkNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.