[PR #5213] [CLOSED] fix(session): update expiresAt in database when preserveSessionInDatabase is enabled #31457

Closed
opened 2026-04-17 22:19:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5213
Author: @notsliver
Created: 10/10/2025
Status: Closed

Base: canaryHead: fix/session-revoke-update-expiredAt


📝 Commits (3)

  • 26b49a5 fix(session): update expiresAt in database when preserveSessionInDatabase is enabled
  • a632137 test(secondary-storage): enhance session verification by filtering active sessions before revocation
  • 397ec79 test(secondary-storage): improve session existence checks by verifying individual active sessions before revocation

📊 Changes

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

View changed files

📝 packages/better-auth/src/db/internal-adapter.ts (+41 -8)
📝 packages/better-auth/src/db/secondary-storage.test.ts (+130 -0)

📄 Description

Fixed Issue #5144


Summary by cubic

Fixes session revocation when preserveSessionInDatabase is enabled: we now update expiresAt to epoch in the database instead of deleting the row, while still clearing secondary storage. This keeps historical session records without leaving active tokens.

  • Bug Fixes
    • Set expiresAt = new Date(0) for revokeSession and revokeSessions when preserveSessionInDatabase: true; otherwise behavior is unchanged.
    • Clear secondary storage entries and add tests to verify DB expiry updates and cache removal.

🔄 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/5213 **Author:** [@notsliver](https://github.com/notsliver) **Created:** 10/10/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/session-revoke-update-expiredAt` --- ### 📝 Commits (3) - [`26b49a5`](https://github.com/better-auth/better-auth/commit/26b49a5168ada61e624d7c41c20c5e41e7cb50fc) fix(session): update expiresAt in database when preserveSessionInDatabase is enabled - [`a632137`](https://github.com/better-auth/better-auth/commit/a6321379a9ff8680dacc4dd919b312c49aac6cae) test(secondary-storage): enhance session verification by filtering active sessions before revocation - [`397ec79`](https://github.com/better-auth/better-auth/commit/397ec7981e3991910f9d820e5231efd13909144a) test(secondary-storage): improve session existence checks by verifying individual active sessions before revocation ### 📊 Changes **2 files changed** (+171 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/internal-adapter.ts` (+41 -8) 📝 `packages/better-auth/src/db/secondary-storage.test.ts` (+130 -0) </details> ### 📄 Description Fixed [Issue #5144](https://github.com/better-auth/better-auth/issues/5144) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes session revocation when preserveSessionInDatabase is enabled: we now update expiresAt to epoch in the database instead of deleting the row, while still clearing secondary storage. This keeps historical session records without leaving active tokens. - **Bug Fixes** - Set expiresAt = new Date(0) for revokeSession and revokeSessions when preserveSessionInDatabase: true; otherwise behavior is unchanged. - Clear secondary storage entries and add tests to verify DB expiry updates and cache removal. <!-- 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 22:19:55 -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#31457