[PR #6700] [MERGED] fix: prevent stateless refresh with database configured #6834

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6700
Author: @Bekacru
Created: 12/11/2025
Status: Merged
Merged: 12/13/2025
Merged by: @Bekacru

Base: canaryHead: fix/session-cache


📝 Commits (2)

  • c7f0393 fix: prevent stateless refresh with database configured
  • 9cef362 test: add tests for cookieRefreshCache behavior with database and secondaryStorage configurations

📊 Changes

4 files changed (+73 additions, -4 deletions)

View changed files

📝 packages/better-auth/src/api/routes/session-api.test.ts (+6 -3)
📝 packages/better-auth/src/api/routes/session.ts (+4 -1)
📝 packages/better-auth/src/context/create-context.test.ts (+52 -0)
📝 packages/better-auth/src/context/create-context.ts (+11 -0)

📄 Description

Summary by cubic

Prevent stateless cookie-cache refresh when a database or secondary storage is configured. This avoids mixed configurations and improves session expiry handling.

  • Bug Fixes
    • Disable session.cookieCache.refreshCache in stateful setups and log a warning to guide configuration.
    • Normalize cached expiresAt to a Date before comparison to avoid incorrect expiration checks.

Written for commit 9cef3626ed. 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/6700 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 12/11/2025 **Status:** ✅ Merged **Merged:** 12/13/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/session-cache` --- ### 📝 Commits (2) - [`c7f0393`](https://github.com/better-auth/better-auth/commit/c7f0393218909389e950ffc5085c650bdebd2eaf) fix: prevent stateless refresh with database configured - [`9cef362`](https://github.com/better-auth/better-auth/commit/9cef3626ed570a5db464794943fa21c610bec022) test: add tests for cookieRefreshCache behavior with database and secondaryStorage configurations ### 📊 Changes **4 files changed** (+73 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/session-api.test.ts` (+6 -3) 📝 `packages/better-auth/src/api/routes/session.ts` (+4 -1) 📝 `packages/better-auth/src/context/create-context.test.ts` (+52 -0) 📝 `packages/better-auth/src/context/create-context.ts` (+11 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Prevent stateless cookie-cache refresh when a database or secondary storage is configured. This avoids mixed configurations and improves session expiry handling. - **Bug Fixes** - Disable session.cookieCache.refreshCache in stateful setups and log a warning to guide configuration. - Normalize cached expiresAt to a Date before comparison to avoid incorrect expiration checks. <sup>Written for commit 9cef3626ed570a5db464794943fa21c610bec022. 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:13:16 -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#6834