[PR #7943] feat: add countOn option for rate limiter #33243

Open
opened 2026-04-17 23:53:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7943
Author: @himself65
Created: 2/12/2026
Status: 🔄 Open

Base: nextHead: himself65/2026/02/12/count


📝 Commits (1)

  • ce704b6 feat: add countOn option for rate limiter

📊 Changes

4 files changed (+142 additions, -27 deletions)

View changed files

📝 packages/better-auth/src/api/index.ts (+1 -1)
📝 packages/better-auth/src/api/rate-limiter/index.ts (+21 -15)
📝 packages/better-auth/src/api/rate-limiter/rate-limiter.test.ts (+109 -0)
📝 packages/core/src/types/init-options.ts (+11 -11)

📄 Description

Summary by cubic

Add a countOn option to the rate limiter to control when requests are counted (all vs error). This lets you count only failed responses to avoid throttling successful flows.

  • New Features

    • countOn in rate limit config: "all" (default) or "error" (only status >= 400 are counted).
    • Per-path customRules can set countOn.
    • Counting now occurs after response and respects countOn; tests cover both modes.
  • Migration

    • customRules no longer accept functions; use static rule objects or false per path.

Written for commit ce704b626b. 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/7943 **Author:** [@himself65](https://github.com/himself65) **Created:** 2/12/2026 **Status:** 🔄 Open **Base:** `next` ← **Head:** `himself65/2026/02/12/count` --- ### 📝 Commits (1) - [`ce704b6`](https://github.com/better-auth/better-auth/commit/ce704b626b76b446d5da7254da917fe036a56641) feat: add `countOn` option for rate limiter ### 📊 Changes **4 files changed** (+142 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/index.ts` (+1 -1) 📝 `packages/better-auth/src/api/rate-limiter/index.ts` (+21 -15) 📝 `packages/better-auth/src/api/rate-limiter/rate-limiter.test.ts` (+109 -0) 📝 `packages/core/src/types/init-options.ts` (+11 -11) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add a countOn option to the rate limiter to control when requests are counted (all vs error). This lets you count only failed responses to avoid throttling successful flows. - **New Features** - countOn in rate limit config: "all" (default) or "error" (only status >= 400 are counted). - Per-path customRules can set countOn. - Counting now occurs after response and respects countOn; tests cover both modes. - **Migration** - customRules no longer accept functions; use static rule objects or false per path. <sup>Written for commit ce704b626b76b446d5da7254da917fe036a56641. 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-17 23:53:42 -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#33243