Repository navigation
Provide the seconds until retry in @throttle rate limit errors - #2830
officialasishkumar wants to merge 1 commit into
Conversation
When `@throttle` rejects a field, clients only got the message "Try again later." without knowing when they may actually retry, since the decay time depends on the configured limiter. `RateLimitException` now implements `ProvidesExtensions` and accepts the number of seconds until the field is accessible again. `@throttle` fills it from the rate limiter's `availableIn()` for the limit that was exceeded, which is what Laravel's `ThrottleRequests` middleware sends in the `Retry-After` header. Clients find it in `extensions.retryAfter` of the error. The message and constructor stay compatible, the extension is omitted when the exception is created without a value. Resolves nuwave#2450
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
The failing |
Resolves #2450
Changes
When
@throttlerejects a field, the error now tells clients when they may retry:{ "errors": [ { "message": "Rate limit for Query.foo exceeded. Try again later.", "extensions": { "retryAfter": 42 } } ] }retryAfteris the number of seconds until the field is accessible again, taken fromRateLimiter::availableIn()for the limit that was exceeded.That is the same value Laravel's
ThrottleRequestsmiddleware sends in theRetry-Afterheader.For named limiters that return several limits, it belongs to the first exceeded limit, as in
ThrottleRequests.RateLimitExceptionimplementsProvidesExtensionsand takes the seconds as an optional second constructor argument.The message stays the same, and an exception created without the seconds has no extensions, so existing code that throws or asserts it keeps working.
Breaking changes
None.
Changelog
Added
extensions.retryAfterof@throttlerate limit errors