Skip to content

Comments

feat: add optional HTTP retry for Web API (429, 5xx, connection errors)#1532

Open
olegbespalov wants to merge 2 commits intoslack-go:masterfrom
olegbespalov:feat/option-retry
Open

feat: add optional HTTP retry for Web API (429, 5xx, connection errors)#1532
olegbespalov wants to merge 2 commits intoslack-go:masterfrom
olegbespalov:feat/option-retry

Conversation

@olegbespalov
Copy link
Contributor

What?

This PR adds optional HTTP retries for the Web API client. Retries are off by default. You can turn them on with OptionRetry(n) for simple 429-only retries or OptionRetryConfig(cfg) when you want full control.

It's also possible to opt-in 5xx retries via NewServerErrorRetryHandler(cfg). For 5xx and connection errors, we also use exponential backoff from the config. Multipart and other streaming requests are left as-is and are not retried.

Why?

Without retries, a single 429, 5xx, or connection blip often forces callers to implement their retry and backoff. Enabling retries via one option improves reliability under rate limits, server issues, and flaky networks without pushing that logic onto every user.

Defaulting to 429-only keeps behavior predictable; users who want connection or 5xx retries can add the right handlers.

Closes #1531

Add OptionRetry(n) and OptionRetryConfig(cfg). Retries are off by default.
OptionRetry enables 429-only retries; OptionRetryConfig supports pluggable
handlers (connection, 429, opt-in 5xx). Respect Retry-After for 429 and
exponential backoff for 5xx/connection. Set GetBody on form/JSON so body
can be re-sent; streaming requests are not retried. Aligns with Python SDK.
@olegbespalov olegbespalov changed the title feat: Add optional HTTP retry for Web API (429, 5xx, connection errors) feat: add optional HTTP retry for Web API (429, 5xx, connection errors) Feb 22, 2026
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.

Feature: Optional HTTP retries for Web API calls (429, 5xx, connection errors)

1 participant