Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[RateLimiter] Fix RateLimit->getRetryAfter() return value when consuming 0 or last tokens#53282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@wouterj
Copy link
Member

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
Issues-
LicenseMIT

Replaces#52835 Original description:

Have got some BC after updating the project to Symfony 6.4 (after that PR#51676).

Sometimes I need to getRateLimit object without consuming just before consuming a try, in example:

$rateLimit =$limiter->consume(0);if ($rateLimit->getRemainingTokens() ===0) {thrownewSomeException($rateLimit->getRetryAfter());}...$limiter->consume(1)...

and found that in that case$rateLimit->getRetryAfter() always returnsnow.

So this PR fixes it.

@carsonbotcarsonbot added this to the6.4 milestoneDec 29, 2023
@OskarStarkOskarStark changed the title[RateLimiter] Fix RateLimit->getRetryAfter() return value when consuming 0 or last tokens.[RateLimiter] Fix RateLimit->getRetryAfter() return value when consuming 0 or last tokensDec 29, 2023
@nicolas-grekasnicolas-grekasforce-pushed thefix_rate_limit_bc_after_51676_pr branch from701dc3c to677b8b7CompareDecember 30, 2023 09:55
@nicolas-grekas
Copy link
Member

Thank you@wouterj.

@nicolas-grekasnicolas-grekas merged commit4e10a49 intosymfony:6.4Dec 30, 2023
@nicolas-grekas
Copy link
Member

And thank you@ERuban

@wouterjwouterj deleted the fix_rate_limit_bc_after_51676_pr branchDecember 30, 2023 10:13
This was referencedDec 30, 2023
@ERuban
Copy link
Contributor

Huh, have found that this PR didn't fix some cases that was fixed by my ones.

  1. if you will try to checkgetRetryAfter right after using the last token(s) - then it will always returnnow() but it should be a time when first attempt will be available

  2. When there is no available tokens and 0 is consumed thengetRetryAfter will show the time when all tokens will be available...

/cc@wouterj

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

4 participants

@wouterj@nicolas-grekas@ERuban@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp