[PR #7048] [MERGED] fix(client): apply rate limit focus refetch regardless of session state #7043

Closed
opened 2026-03-13 13:22:12 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7048
Author: @bytaesu
Created: 12/29/2025
Status: Merged
Merged: 12/29/2025
Merged by: @himself65

Base: canaryHead: 2025-12-29/fix/session-refetch-rate-limit


📝 Commits (2)

  • d89b5ce fix(client): apply rate limit focus refetch regardless of session state
  • 06128e4 Merge branch 'canary' into 2025-12-29/fix/session-refetch-rate-limit

📊 Changes

2 files changed (+8 additions, -14 deletions)

View changed files

📝 packages/better-auth/src/client/session-refresh.test.ts (+6 -6)
📝 packages/better-auth/src/client/session-refresh.ts (+2 -8)

📄 Description

Unless there's a specific reason not to, it seems appropriate to apply rate limiting even when there's no session.

cc @ping-maxwell


Before

https://github.com/user-attachments/assets/478fbf31-de21-443c-a79f-c92a82a8955e

After

https://github.com/user-attachments/assets/cd3eb638-e545-48e9-8b07-116850fcd5c5


Summary by cubic

Apply focus refetch rate limiting even when the session is null or undefined to prevent unnecessary requests on visibility change and keep behavior consistent.

  • Bug Fixes
    • Removed the bypass that refetched on focus when session was null/undefined.
    • Set lastSessionRequest on visibilitychange and skip refetch if within the rate limit window.
    • Updated tests to assert rate limiting applies for null and undefined sessions.

Written for commit 06128e414e. Summary will update automatically 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/7048 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 12/29/2025 **Status:** ✅ Merged **Merged:** 12/29/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2025-12-29/fix/session-refetch-rate-limit` --- ### 📝 Commits (2) - [`d89b5ce`](https://github.com/better-auth/better-auth/commit/d89b5ceda8bf009ca8839c2ec5dd19c61943e321) fix(client): apply rate limit focus refetch regardless of session state - [`06128e4`](https://github.com/better-auth/better-auth/commit/06128e414e880ae80c7016a92e42817ac7790259) Merge branch 'canary' into 2025-12-29/fix/session-refetch-rate-limit ### 📊 Changes **2 files changed** (+8 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/session-refresh.test.ts` (+6 -6) 📝 `packages/better-auth/src/client/session-refresh.ts` (+2 -8) </details> ### 📄 Description Unless there's a specific reason not to, it seems appropriate to apply rate limiting even when there's no session. cc @ping-maxwell --- ### Before https://github.com/user-attachments/assets/478fbf31-de21-443c-a79f-c92a82a8955e ### After https://github.com/user-attachments/assets/cd3eb638-e545-48e9-8b07-116850fcd5c5 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Apply focus refetch rate limiting even when the session is null or undefined to prevent unnecessary requests on visibility change and keep behavior consistent. - **Bug Fixes** - Removed the bypass that refetched on focus when session was null/undefined. - Set lastSessionRequest on visibilitychange and skip refetch if within the rate limit window. - Updated tests to assert rate limiting applies for null and undefined sessions. <sup>Written for commit 06128e414e880ae80c7016a92e42817ac7790259. Summary will update automatically 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:22:12 -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#7043