[PR #7161] [MERGED] fix: clean up expired rate-limit entries on memory storage #7110

Closed
opened 2026-03-13 13:24:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7161
Author: @ping-maxwell
Created: 1/7/2026
Status: Merged
Merged: 1/7/2026
Merged by: @himself65

Base: canaryHead: fix/prevent-memory-leak-with-memory-rate-limit


📝 Commits (1)

  • 01b1506 fix: prevent memory leak with memory rate-limit

📊 Changes

1 file changed (+23 additions, -3 deletions)

View changed files

📝 packages/better-auth/src/api/rate-limiter/index.ts (+23 -3)

📄 Description

We don't clean up expired rate-limit entries on memory storage. This PR adds simple logic to remove those rate-limit entries upon expiration


Summary by cubic

Fixes a memory leak in the in-memory rate limiter by expiring and cleaning entries based on the configured rate-limit window.

  • Bug Fixes
    • Store entries with an expiresAt derived from the rate-limit window (default 10s).
    • On get, remove expired entries and return undefined.

Written for commit 01b1506ca2. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7161 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 1/7/2026 **Status:** ✅ Merged **Merged:** 1/7/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/prevent-memory-leak-with-memory-rate-limit` --- ### 📝 Commits (1) - [`01b1506`](https://github.com/better-auth/better-auth/commit/01b1506ca26d0ac481acc42cf44d4a542c8c6db6) fix: prevent memory leak with memory rate-limit ### 📊 Changes **1 file changed** (+23 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/rate-limiter/index.ts` (+23 -3) </details> ### 📄 Description We don't clean up expired rate-limit entries on memory storage. This PR adds simple logic to remove those rate-limit entries upon expiration <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes a memory leak in the in-memory rate limiter by expiring and cleaning entries based on the configured rate-limit window. - **Bug Fixes** - Store entries with an expiresAt derived from the rate-limit window (default 10s). - On get, remove expired entries and return undefined. <sup>Written for commit 01b1506ca26d0ac481acc42cf44d4a542c8c6db6. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:24:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7110