Repository navigation
Freeze time in the rate-limit header tests - #7
Merged
Merged
Conversation
The limiter counts whole seconds, so a run whose requests straddled a second boundary got Retry-After: 59 and t=59 where the tests asserted 60. It failed CI once on PHP 8.4, on the merge of #5. With time frozen in beforeEach, every request in a test lands in one second, and the test that travels 20 seconds still does.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RateLimitHeadersTestfailed CI once on PHP 8.4 (the merge of #5):Retry-Afterwas59where the test asserted60. The limiter counts whole seconds, so when a test's requests straddle a second boundary, the window has a second less left by the time the 429 is built.beforeEachnow freezes time, so every request in a test lands in one second. The test that needs time to pass already usestravel(), which moves the frozen clock.Reproduced, then fixed: with a temporary loop making each test start just before a second boundary, the file failed exactly as CI did without the freeze (
answers 429 with the apiguide.dev type, Retry-After…), and passed with it. That loop isn't in the PR. The file also passed 15 runs in a row, and the full suite passes.