[PR #7097] [MERGED] fix(core): detect dual module error #23974

Closed
opened 2026-04-15 22:05:53 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7097
Author: @himself65
Created: 1/2/2026
Status: Merged
Merged: 1/3/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/01/02/dual-module


📝 Commits (2)

  • b562620 fix(core): dual module error
  • 83b3607 fix(core): dual module error

📊 Changes

1 file changed (+29 additions, -0 deletions)

View changed files

📝 packages/core/src/context/index.ts (+29 -0)

📄 Description

Related to https://github.com/better-auth/better-auth/issues/6613


Summary by cubic

Added a global import guard to prevent loading multiple versions of Better Auth. This avoids broken AsyncLocalStorage and request state sync issues.

  • Bug Fixes
    • Detects duplicate imports across Node and browser via globalThis/window/global.
    • Logs a clear console error if Better Auth is imported more than once.
    • Ensures a single AsyncLocalStorage instance per request.

Written for commit 83b3607106. 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/7097 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/2/2026 **Status:** ✅ Merged **Merged:** 1/3/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/01/02/dual-module` --- ### 📝 Commits (2) - [`b562620`](https://github.com/better-auth/better-auth/commit/b5626209bea071f985b3c7c3e17867a9c156bde3) fix(core): dual module error - [`83b3607`](https://github.com/better-auth/better-auth/commit/83b3607106ad912588ace88d47cd9b87cc3d2dcd) fix(core): dual module error ### 📊 Changes **1 file changed** (+29 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/context/index.ts` (+29 -0) </details> ### 📄 Description Related to https://github.com/better-auth/better-auth/issues/6613 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Added a global import guard to prevent loading multiple versions of Better Auth. This avoids broken AsyncLocalStorage and request state sync issues. - **Bug Fixes** - Detects duplicate imports across Node and browser via globalThis/window/global. - Logs a clear console error if Better Auth is imported more than once. - Ensures a single AsyncLocalStorage instance per request. <sup>Written for commit 83b3607106ad912588ace88d47cd9b87cc3d2dcd. 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-15 22:05:53 -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#23974