Skip to content

Freeze time in the rate-limit header tests - #7

Merged
JustSteveKing merged 1 commit into
mainfrom
fix/rate-limit-tests-freeze-time
Oct 30, 2026
Merged

JustSteveKing merged 1 commit into
mainfrom
fix/rate-limit-tests-freeze-time

Conversation

@JustSteveKing

Copy link
Copy Markdown
Owner

RateLimitHeadersTest failed CI once on PHP 8.4 (the merge of #5): Retry-After was 59 where the test asserted 60. 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.

beforeEach now freezes time, so every request in a test lands in one second. The test that needs time to pass already uses travel(), 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.

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.
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0d8a869f-c1ca-4a68-9206-8217de388fbb
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JustSteveKing JustSteveKing self-assigned this Oct 30, 2026
@JustSteveKing
JustSteveKing merged commit 83a49ff into main Oct 30, 2026
7 checks passed
@JustSteveKing
JustSteveKing deleted the fix/rate-limit-tests-freeze-time branch October 30, 2026 09:48
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.

1 participant