Skip to content

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

Merged
nlopes merged 1 commit into
slack-go:masterfrom
olegbespalov:feat/option-retry
Feb 26, 2026
Merged

feat: add optional HTTP retry for Web API (429, 5xx, connection errors)#1532
nlopes merged 1 commit into
slack-go:masterfrom
olegbespalov:feat/option-retry

Conversation

@olegbespalov

Copy link
Copy Markdown
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

@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
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.
@nlopes nlopes merged commit 777ee2f into slack-go:master Feb 26, 2026
4 checks passed
@nlopes nlopes self-assigned this Feb 26, 2026
@nlopes nlopes added this to the v0.19.0 milestone Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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)

2 participants