[PR #7019] [CLOSED] fix: include session id in secondary storage when storeSessionInDatabase is true #32628

Closed
opened 2026-04-17 23:23:31 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7019
Author: @bytaesu
Created: 12/27/2025
Status: Closed

Base: canaryHead: 2025-12-27/fix/internal-adapter-secondary-storage


📝 Commits (10+)

  • aad3b0b fix: include session id in secondary storage when storeSessionInDatabase is true
  • ccba541 refactor: reduce duplicate logic
  • 6e93c9d Merge branch 'canary' into 2025-12-27/fix/internal-adapter-secondary-storage
  • f5b9a31 fix: use getCurrentAdapter
  • a326fe1 Merge branch 'canary' into 2025-12-27/fix/internal-adapter-secondary-storage
  • 2cf9c08 Merge branch 'canary' into 2025-12-27/fix/internal-adapter-secondary-storage
  • 3a0a0d3 test: restore test case
  • 1df8962 Merge branch 'canary' into 2025-12-27/fix/internal-adapter-secondary-storage
  • d6525a2 chore: add comment
  • 2a549c0 test: update case

📊 Changes

2 files changed (+106 additions, -24 deletions)

View changed files

📝 packages/better-auth/src/db/internal-adapter.test.ts (+74 -0)
📝 packages/better-auth/src/db/internal-adapter.ts (+32 -24)

📄 Description


Summary by cubic

Fixes missing session.id in secondary storage when storeSessionInDatabase is enabled, ensuring consistent lookups and cache correctness. Also aligns secondary storage TTL with session expiry.

  • Bug Fixes
    • When storeSessionInDatabase is true, write the created session (with id) and user to secondary storage after DB save using getCurrentAdapter.
    • Set TTL from expiresAt; skip write if TTL <= 0.
    • Added test to verify session.id is present in secondary storage and in DB.

Written for commit 2a549c067e. 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/7019 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 12/27/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `2025-12-27/fix/internal-adapter-secondary-storage` --- ### 📝 Commits (10+) - [`aad3b0b`](https://github.com/better-auth/better-auth/commit/aad3b0be13a0a7f842fb7d29fc62e345772599f2) fix: include session id in secondary storage when storeSessionInDatabase is true - [`ccba541`](https://github.com/better-auth/better-auth/commit/ccba54134c632345d59014d1a5148e5295f9b88a) refactor: reduce duplicate logic - [`6e93c9d`](https://github.com/better-auth/better-auth/commit/6e93c9dc504315975649add9727a1267c85778bd) Merge branch 'canary' into 2025-12-27/fix/internal-adapter-secondary-storage - [`f5b9a31`](https://github.com/better-auth/better-auth/commit/f5b9a31d32daae17ffe8a9c57ad8dbd8f973cfcc) fix: use getCurrentAdapter - [`a326fe1`](https://github.com/better-auth/better-auth/commit/a326fe1fca15b1c70c89ca0fc7e9292fa32db15c) Merge branch 'canary' into 2025-12-27/fix/internal-adapter-secondary-storage - [`2cf9c08`](https://github.com/better-auth/better-auth/commit/2cf9c085b92beac88d47becf9bc4a9d17ec774b1) Merge branch 'canary' into 2025-12-27/fix/internal-adapter-secondary-storage - [`3a0a0d3`](https://github.com/better-auth/better-auth/commit/3a0a0d3bf6e69020810b264080a5b812716d77ad) test: restore test case - [`1df8962`](https://github.com/better-auth/better-auth/commit/1df8962cbdaa8df1372616835bfa5cad237929df) Merge branch 'canary' into 2025-12-27/fix/internal-adapter-secondary-storage - [`d6525a2`](https://github.com/better-auth/better-auth/commit/d6525a2e05c5c50cf587db5feeee2a1434dd5f24) chore: add comment - [`2a549c0`](https://github.com/better-auth/better-auth/commit/2a549c067e66867ac19f2a137dc457803a6b9f12) test: update case ### 📊 Changes **2 files changed** (+106 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/internal-adapter.test.ts` (+74 -0) 📝 `packages/better-auth/src/db/internal-adapter.ts` (+32 -24) </details> ### 📄 Description - Closes https://github.com/better-auth/better-auth/issues/6993 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes missing session.id in secondary storage when storeSessionInDatabase is enabled, ensuring consistent lookups and cache correctness. Also aligns secondary storage TTL with session expiry. - **Bug Fixes** - When storeSessionInDatabase is true, write the created session (with id) and user to secondary storage after DB save using getCurrentAdapter. - Set TTL from expiresAt; skip write if TTL <= 0. - Added test to verify session.id is present in secondary storage and in DB. <sup>Written for commit 2a549c067e66867ac19f2a137dc457803a6b9f12. 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:23:31 -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#32628