[PR #7939] [MERGED] fix: separate rate limit request and response handling #15886

Closed
opened 2026-04-13 10:17:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7939
Author: @himself65
Created: 2/12/2026
Status: Merged
Merged: 2/12/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/02/12/res


📝 Commits (1)

  • 05ca142 fix: separate rate limit request and response handling

📊 Changes

2 files changed (+41 additions, -12 deletions)

View changed files

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

📄 Description

Summary by cubic

Split rate limiting into a request pre-check and a response update to make limits accurate and the flow clearer. The request hook now only validates and can return 429; the response hook updates counters after the response.

  • Bug Fixes
    • Added onResponseRateLimit and call it from router onResponse(req).
    • Request hook only checks limits and returns Retry-After when needed.
    • Response hook updates or resets counts; no limit checks there.
    • Shared resolveRateLimitConfig for both paths; skips when IP is missing.

Written for commit 05ca142064. 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/7939 **Author:** [@himself65](https://github.com/himself65) **Created:** 2/12/2026 **Status:** ✅ Merged **Merged:** 2/12/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/02/12/res` --- ### 📝 Commits (1) - [`05ca142`](https://github.com/better-auth/better-auth/commit/05ca142064ed10b240eefeea2166afb5501f0f52) fix: separate rate limit request and response handling ### 📊 Changes **2 files changed** (+41 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/index.ts` (+3 -2) 📝 `packages/better-auth/src/api/rate-limiter/index.ts` (+38 -10) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Split rate limiting into a request pre-check and a response update to make limits accurate and the flow clearer. The request hook now only validates and can return 429; the response hook updates counters after the response. - **Bug Fixes** - Added onResponseRateLimit and call it from router onResponse(req). - Request hook only checks limits and returns Retry-After when needed. - Response hook updates or resets counts; no limit checks there. - Shared resolveRateLimitConfig for both paths; skips when IP is missing. <sup>Written for commit 05ca142064ed10b240eefeea2166afb5501f0f52. 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-04-13 10:17:17 -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#15886