Skip to content

fix(ratelimit): stop the window parsing differential from flaking at window boundaries - #4

Merged
yordis merged 2 commits into
mainfrom
yordis/test-ratelimit-window-clock
Oct 30, 2026
Merged

yordis merged 2 commits into
mainfrom
yordis/test-ratelimit-window-clock

Conversation

@yordis

@yordis yordis commented Oct 30, 2026

Copy link
Copy Markdown
Member
  • The Redis parity job failed on an unrelated PR because the ratelimit window parsing differential compared the reset time against a clock read taken after the request, so a 1.5 s window boundary landing during the round trip made the reset look already past.
  • A pinned clock reproduces it deterministically, so the flake stays fixed instead of passing on rerun.

…e in the window it runs

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…e so a window boundary cannot flip it

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

TrogonStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.

  • Ask an admin to upgrade

Open in CodeRabbit

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Free
  • Run ID: 7ea3b1e7-7c34-4832-88f8-f52748408a5b
Commits

Reviewing files that changed from the base of the PR and between 7c0ba41 and 374d462.

Files selected for processing: 1
  • packages/next-nats/tests/vitest/differential/ratelimit.behavior.differential.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The differential tests add shared fixed-window result reporting. They compare reset behavior for requests near different window positions. Existing parsing cases use the shared helper and measure reset timing from request start.

Changes

Rate-limit differential test coverage

Layer / File(s) Summary
Shared fixed-window assertions and boundary cases
packages/next-nats/tests/vitest/differential/ratelimit.behavior.differential.test.ts
Adds a helper that reports success, remaining tokens, and whether reset occurs after request start. Adds comparisons for requests near a window boundary and within a later window. Updates parsing cases to use the helper for both implementations.

Estimated code review effort: 2 (Simple) | ~10 minutes

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

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

@yordis
yordis merged commit 4434044 into main Oct 30, 2026
6 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.

1 participant