Skip to content

fix: consolidate duplicate rate limiter implementations#3653

Closed
REHAN-503 wants to merge 3 commits into
JhaSourav07:mainfrom
REHAN-503:fix/consolidate-rate-limiter
Closed

fix: consolidate duplicate rate limiter implementations#3653
REHAN-503 wants to merge 3 commits into
JhaSourav07:mainfrom
REHAN-503:fix/consolidate-rate-limiter

Conversation

@REHAN-503
Copy link
Copy Markdown
Contributor

@REHAN-503 REHAN-503 commented Jun 4, 2026

Description

Fixes #1797

This PR consolidates the application's rate-limiting implementation by removing the standalone middleware-specific rate limiter and reusing the existing RateLimiter class across the codebase.

What changed

  • Removed the standalone rateLimit() implementation from lib/rate-limit.ts
  • Added a dedicated middlewareRateLimiter instance using the existing RateLimiter class
  • Refactored middleware.ts to use middlewareRateLimiter.checkWithResult()
  • Updated affected unit tests to align with the unified implementation
  • Preserved the existing middleware policy of 60 requests per minute

Why

The repository contained two separate rate-limiting implementations:

  1. RateLimiter class backed by DistributedCache / TTL-based storage
  2. Standalone rateLimit() function used by middleware

Pillar

  • Bug Fix
  • Core Feature

Checklist

  • My branch is up to date with the latest changes required for this PR
  • I have tested my changes locally
  • Production build passes successfully
  • TypeScript compilation passes successfully
  • Updated related tests where necessary
  • No unrelated files or dependency changes were included

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 4, 2026

@REHAN-503 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the needs-details This PR is missing required description details. label Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

👋 Hey @REHAN-503, it looks like you didn't use our PR template!

The section ## Description is missing from your PR description.

Please update your PR description to include all required sections so we can review this properly:

  • ## Description — What does this PR do? Which issue does it fix?
  • ## Pillar — Which contribution pillar does this fall under?
  • ## Checklist — Have you ticked off the quality checklist?

You can find the full template in CONTRIBUTING.md. Just edit your PR description and the needs-details label will be removed automatically. 🙌

@github-actions github-actions Bot added needs-rebase This PR has merge conflicts and needs a rebase. and removed needs-details This PR is missing required description details. labels Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

⚠️ Hey @REHAN-503, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@REHAN-503 REHAN-503 force-pushed the fix/consolidate-rate-limiter branch from b43c387 to 5edb179 Compare June 4, 2026 09:17
- Remove duplicate rateLimit() implementation
- Update middleware to use rateLimit() function
- Fix tests to align with new implementation
- Resolve merge conflicts with upstream/main

Fixes JhaSourav07#1797
@github-actions github-actions Bot removed the needs-rebase This PR has merge conflicts and needs a rebase. label Jun 4, 2026
Copy link
Copy Markdown
Collaborator

@Aamod007 Aamod007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Consolidating the rate limiter is a clean refactor.

@Aamod007 Aamod007 added level:beginner Small changes Usually isolated fixes or simple UI/text updates. GSSoC 2026 mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:refactor Code changes that neither fix a bug nor add a feature labels Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

👋 Hey @REHAN-503! Thanks for your contribution! 🎉

Unfortunately, this PR has been automatically closed because it is not linked to any open issue.

To resolve this, please do the following:

  1. Link a valid open issue by editing your PR description to include a closing keyword (e.g., Fixes #<issue-number>).
  2. Reopen this PR once the link is added.

💡 You can link multiple issues if needed (e.g. Fixes #12, Closes #34).
If you're working on something that doesn't have an issue yet, please open one first and then link it here.

We look forward to reviewing your PR once an issue is linked! 🚀

@github-actions github-actions Bot closed this Jun 4, 2026
@REHAN-503 REHAN-503 mentioned this pull request Jun 4, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:refactor Code changes that neither fix a bug nor add a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Consolidate Rate Limiter implementations

2 participants