[PR #7654] [MERGED] chore: should keep singleton of ctx #33070

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7654
Author: @himself65
Created: 1/28/2026
Status: Merged
Merged: 1/30/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/01/27/keep-original


📝 Commits (3)

📊 Changes

4 files changed (+16 additions, -18 deletions)

View changed files

📝 packages/better-auth/src/context/create-context.test.ts (+5 -1)
📝 packages/better-auth/src/context/create-context.ts (+2 -5)
📝 packages/better-auth/src/context/helpers.ts (+5 -9)
📝 packages/better-auth/src/plugins/haveibeenpwned/index.ts (+4 -3)

📄 Description

Summary by cubic

Keep a single AuthContext instance throughout plugin init and context creation to prevent reference changes and stale references. Plugins now mutate the original ctx, and we return the same object.

  • Refactors

    • runPluginInit mutates ctx via Object.assign instead of creating a new context.
    • create-context returns the original ctx.
    • Test added to assert the same ctx instance is used end-to-end.
    • Switched internal adapter import to ../db.
  • Bug Fixes

    • Preserve original password.hash in have-i-been-pwned plugin to avoid recursion after the compromise check.

Written for commit 3fe63b8532. 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/7654 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/28/2026 **Status:** ✅ Merged **Merged:** 1/30/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/01/27/keep-original` --- ### 📝 Commits (3) - [`524308b`](https://github.com/better-auth/better-auth/commit/524308bb05cf883ec62b194b7d1b4152cd406508) chore: should keep singleton of ctx - [`7be150f`](https://github.com/better-auth/better-auth/commit/7be150f9073e9362a1a37695b2a29021352b552f) fix: context - [`3fe63b8`](https://github.com/better-auth/better-auth/commit/3fe63b85321e41d8435e8929d939cbe1f978ccb6) fix: hash ### 📊 Changes **4 files changed** (+16 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/context/create-context.test.ts` (+5 -1) 📝 `packages/better-auth/src/context/create-context.ts` (+2 -5) 📝 `packages/better-auth/src/context/helpers.ts` (+5 -9) 📝 `packages/better-auth/src/plugins/haveibeenpwned/index.ts` (+4 -3) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Keep a single AuthContext instance throughout plugin init and context creation to prevent reference changes and stale references. Plugins now mutate the original ctx, and we return the same object. - **Refactors** - runPluginInit mutates ctx via Object.assign instead of creating a new context. - create-context returns the original ctx. - Test added to assert the same ctx instance is used end-to-end. - Switched internal adapter import to ../db. - **Bug Fixes** - Preserve original password.hash in have-i-been-pwned plugin to avoid recursion after the compromise check. <sup>Written for commit 3fe63b85321e41d8435e8929d939cbe1f978ccb6. 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:44:28 -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#33070