[PR #4020] [MERGED] Fix/custom session mem leak #30741

Closed
opened 2026-04-17 21:46:05 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4020
Author: @tehnrd
Created: 8/15/2025
Status: Merged
Merged: 8/15/2025
Merged by: @Bekacru

Base: canaryHead: fix/custom-session-mem-leak


📝 Commits (5)

📊 Changes

3 files changed (+87 additions, -45 deletions)

View changed files

📝 packages/better-auth/src/api/routes/session.ts (+24 -22)
📝 packages/better-auth/src/plugins/custom-session/custom-session.test.ts (+39 -0)
📝 packages/better-auth/src/plugins/custom-session/index.ts (+24 -23)

📄 Description

Fixes https://github.com/better-auth/better-auth/issues/3991

Prioritization of this would be appreciated. This memory leak has a direct impact on operating costs and application performance.


Summary by cubic

Fixed a memory leak in custom session handling to improve application performance and reduce operating costs. Also updated database migrations to use cascading deletes and correct timestamp defaults.

  • Bug Fixes

  • Patched the getSession query schema to avoid memory leaks when handling custom sessions.

  • Migration

  • Foreign keys for sessions and accounts now use ON DELETE CASCADE.

  • Date fields now default to CURRENT_TIMESTAMP for supported databases.


🔄 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/4020 **Author:** [@tehnrd](https://github.com/tehnrd) **Created:** 8/15/2025 **Status:** ✅ Merged **Merged:** 8/15/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/custom-session-mem-leak` --- ### 📝 Commits (5) - [`10b1b52`](https://github.com/better-auth/better-auth/commit/10b1b529306366ab900703deb1501120d54226d7) fix: memory leak with getSession - [`1f9aebe`](https://github.com/better-auth/better-auth/commit/1f9aebe77aaaefaf979c193f29f69840d1926b3a) test - [`a91ac85`](https://github.com/better-auth/better-auth/commit/a91ac85dade19ff60a46cb0614d397ce2312ae68) lint - [`1bea2ba`](https://github.com/better-auth/better-auth/commit/1bea2ba559284c11522ce03de33b06b059732d74) Merge branch 'canary' into fix/custom-session-mem-leak - [`90ccd69`](https://github.com/better-auth/better-auth/commit/90ccd69bd7b74ffab66bcfa938c17a651ade7bbe) chore: remove unnecessary comment ### 📊 Changes **3 files changed** (+87 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/session.ts` (+24 -22) 📝 `packages/better-auth/src/plugins/custom-session/custom-session.test.ts` (+39 -0) 📝 `packages/better-auth/src/plugins/custom-session/index.ts` (+24 -23) </details> ### 📄 Description Fixes https://github.com/better-auth/better-auth/issues/3991 Prioritization of this would be appreciated. This memory leak has a direct impact on operating costs and application performance. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed a memory leak in custom session handling to improve application performance and reduce operating costs. Also updated database migrations to use cascading deletes and correct timestamp defaults. - **Bug Fixes** - Patched the getSession query schema to avoid memory leaks when handling custom sessions. - **Migration** - Foreign keys for sessions and accounts now use ON DELETE CASCADE. - Date fields now default to CURRENT_TIMESTAMP for supported databases. <!-- 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 21:46:05 -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#30741