[PR #5031] [MERGED] fix: cookie size limit shouldn't throw error #5728

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5031
Author: @Bekacru
Created: 10/2/2025
Status: Merged
Merged: 10/2/2025
Merged by: @himself65

Base: canaryHead: fix/cookie-cache


📝 Commits (3)

  • 995292c fix: cookie size limit shouldn't throw error
  • fba26bd chore: remove optional chaining
  • cafb471 test: add

📊 Changes

3 files changed (+68 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/api/routes/sign-up.ts (+1 -0)
📝 packages/better-auth/src/cookies/cookies.test.ts (+64 -0)
📝 packages/better-auth/src/cookies/index.ts (+3 -2)

📄 Description

Currently, we throw an error when session data exceeds the cookie size limit. Instead, we should log the error and skip setting the cookie cache. This will allow caching of other smaller data without requiring cookie caching to be disabled entirely

This is a temporary fix until we introduce cookie chunking (#4697)


Summary by cubic

Stop throwing an error when session data exceeds the cookie size limit. We now log the issue and skip setting the session cookie so other cache operations continue. Temporary until we add cookie chunking (#4697).

  • Bug Fixes
    • Cookie cache: when data > 4093 bytes, log the size and skip setting the cookie instead of throwing.
    • Sign-up: log non-API errors when user creation fails for better visibility.

🔄 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/5031 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 10/2/2025 **Status:** ✅ Merged **Merged:** 10/2/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/cookie-cache` --- ### 📝 Commits (3) - [`995292c`](https://github.com/better-auth/better-auth/commit/995292cae26bf88b83196c62565d8a4ac94053d6) fix: cookie size limit shouldn't throw error - [`fba26bd`](https://github.com/better-auth/better-auth/commit/fba26bde55394a9a4e968eafdedb6819aa09dba2) chore: remove optional chaining - [`cafb471`](https://github.com/better-auth/better-auth/commit/cafb47135dd7e94d1fbb8fd326d70406ca0f8aea) test: add ### 📊 Changes **3 files changed** (+68 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+1 -0) 📝 `packages/better-auth/src/cookies/cookies.test.ts` (+64 -0) 📝 `packages/better-auth/src/cookies/index.ts` (+3 -2) </details> ### 📄 Description Currently, we throw an error when session data exceeds the cookie size limit. Instead, we should log the error and skip setting the cookie cache. This will allow caching of other smaller data without requiring cookie caching to be disabled entirely This is a temporary fix until we introduce cookie chunking (#4697) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Stop throwing an error when session data exceeds the cookie size limit. We now log the issue and skip setting the session cookie so other cache operations continue. Temporary until we add cookie chunking (#4697). - **Bug Fixes** - Cookie cache: when data > 4093 bytes, log the size and skip setting the cookie instead of throwing. - Sign-up: log non-API errors when user creation fails for better visibility. <!-- 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 12:33: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#5728