[PR #4812] [MERGED] fix: allow getSession to return null #13835

Closed
opened 2026-04-13 09:10:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4812
Author: @jcajuab
Created: 9/22/2025
Status: Merged
Merged: 9/23/2025
Merged by: @Bekacru

Base: canaryHead: fix/allow-get-session-to-return-null


📝 Commits (2)

  • 3a947c3 fix: allow getSession to return null
  • bfb6ff1 fix: refactor getSession return type while allowing to return null

📊 Changes

1 file changed (+6 additions, -5 deletions)

View changed files

📝 packages/better-auth/src/types/api.ts (+6 -5)

📄 Description

closes #4790


Summary by cubic

Allow getSession to return null when no session exists, aligning types with runtime behavior and preventing false-positive type errors. Fixes #4790.

  • Bug Fixes
    • Updated InferSessionAPI so getSession resolves to the session object (with headers when requested) or null.
    • No breaking changes; runtime behavior unchanged.

🔄 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/4812 **Author:** [@jcajuab](https://github.com/jcajuab) **Created:** 9/22/2025 **Status:** ✅ Merged **Merged:** 9/23/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/allow-get-session-to-return-null` --- ### 📝 Commits (2) - [`3a947c3`](https://github.com/better-auth/better-auth/commit/3a947c3dfcf7ce1f1d28c5fc6ef80b9a58317cca) fix: allow `getSession` to return `null` - [`bfb6ff1`](https://github.com/better-auth/better-auth/commit/bfb6ff1a0b5b91faacefda26566add6e416f3bbf) fix: refactor getSession return type while allowing to return null ### 📊 Changes **1 file changed** (+6 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/types/api.ts` (+6 -5) </details> ### 📄 Description closes #4790 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Allow getSession to return null when no session exists, aligning types with runtime behavior and preventing false-positive type errors. Fixes #4790. - **Bug Fixes** - Updated InferSessionAPI so getSession resolves to the session object (with headers when requested) or null. - No breaking changes; runtime behavior unchanged. <!-- 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-13 09:10:21 -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#13835