Skip to content

Retry transient upstream errors on image-modality requests - #143

Closed
kyto-agent wants to merge 1 commit into
hackclub:mainfrom
kyto-agent:image-request-retries
Closed

kyto-agent wants to merge 1 commit into
hackclub:mainfrom
kyto-agent:image-request-retries

Conversation

@kyto-agent

Copy link
Copy Markdown
Contributor

What

fetchWithRetries gains a skipHeaderTimeout option. Image-modality requests now route through it with skipHeaderTimeout: true, instead of bypassing the helper entirely via a bare fetch.

Why

Image requests bypassed the header-timeout guard (they can take 10-30s+ to return headers), but the bypass also dropped all retry handling. So an upstream OpenRouter 429 ("Rate limit exceeded") on an image edit was passed straight through to the client with zero retries, while text requests retried 429/502/503/504 twice.

Confirmed live in #hack-club-ai support: a user's >1080p image edits consistently fail with a 429 whose body is OpenRouter's "Rate limit exceeded" wording, while smaller images pass. With retries, the transient provider rate-limit now gets its two attempts plus Retry-After backoff like every other request.

Header timeout behavior for image requests is unchanged (still no 15s guard).

Verification

tsc --noEmit clean.

Image-modality requests (text-to-image, image editing) bypassed
fetchWithRetries entirely because they must skip the 15s header timeout.
That also dropped retry handling: an upstream OpenRouter 429
("Rate limit exceeded") on an image edit was passed straight through to
the client with no retry, while text requests retried it twice.

Refactor fetchWithRetries to take a skipHeaderTimeout option so image
requests keep retrying transient upstream failures without the header
timeout guard.
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