Skip to content

Fix | Retry via connector when rate limit sleep follows manual exceed#29

Merged
Sammyjo20 merged 2 commits intosaloonphp:v2from
JonPurvis:saloon-issue-532
Mar 25, 2026
Merged

Fix | Retry via connector when rate limit sleep follows manual exceed#29
Sammyjo20 merged 2 commits intosaloonphp:v2from
JonPurvis:saloon-issue-532

Conversation

@JonPurvis
Copy link
Contributor

@JonPurvis JonPurvis commented Mar 22, 2026

Fixes saloonphp/saloon#532

When HasRateLimits is applied to a Request (not a Connector), a 429 handled with getTooManyAttemptsLimiter()->sleep() triggers a retry that called $this->send(). send() exists on Connector, not Request, so the retry fails (e.g. BadMethodCallException via Macroable, or an undefined-method error depending on context).

This PR introduces some changes:

Retry using $response->getConnector()->send($response->getRequest()) so the retry always goes through the connector.
Use $limitThatWasExceeded->getShouldSleep() instead of the loop’s last $limit when deciding whether to throw vs sleep/retry.

@Sammyjo20 Sammyjo20 changed the title retry via connector when rate limit sleep follows manual exceed Fix | Retry via connector when rate limit sleep follows manual exceed Mar 25, 2026
@Sammyjo20 Sammyjo20 merged commit bdd7bf1 into saloonphp:v2 Mar 25, 2026
26 checks passed
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.

HasRateLimits on Request class throws "Call to undefined method send()" when 429 with sleep() is triggered

2 participants