[PR #7758] [MERGED] fix(adapter): use getCurrentAdapter for user lookup to avoid transaction deadlock #33137

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

📋 Pull Request Information

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

Base: canaryHead: fix/db/transaction-deadlock-use-current-adapter


📝 Commits (1)

  • 74116c4 fix: use getCurrentAdapter for user lookup to avoid transaction deadlock

📊 Changes

1 file changed (+3 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/db/internal-adapter.ts (+3 -1)

📄 Description

  • Problem: direct calls to adapter.findOne(...) can bypass the transaction-bound adapter when running inside runWithTransaction, causing potential deadlocks.
  • Fix: replace direct adapter.findOne calls with await (await getCurrentAdapter(adapter)).findOne(...) so lookups use the transaction-aware adapter.
  • Impact: prevents transaction deadlocks during user lookup; run transactional tests to verify.

Summary by cubic

Route user lookups in InternalAdapter through getCurrentAdapter so they use the transaction-bound adapter. Prevents deadlocks when running inside runWithTransaction.

Written for commit 74116c483a. 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/7758 **Author:** [@sakamoto-wk](https://github.com/sakamoto-wk) **Created:** 2/2/2026 **Status:** ✅ Merged **Merged:** 2/3/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/db/transaction-deadlock-use-current-adapter` --- ### 📝 Commits (1) - [`74116c4`](https://github.com/better-auth/better-auth/commit/74116c483a5fa8cdc2254fc804aea46df5898bf6) fix: use getCurrentAdapter for user lookup to avoid transaction deadlock ### 📊 Changes **1 file changed** (+3 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/internal-adapter.ts` (+3 -1) </details> ### 📄 Description - Problem: direct calls to adapter.findOne(...) can bypass the transaction-bound adapter when running inside runWithTransaction, causing potential deadlocks. - Fix: replace direct adapter.findOne calls with await (await getCurrentAdapter(adapter)).findOne(...) so lookups use the transaction-aware adapter. - Impact: prevents transaction deadlocks during user lookup; run transactional tests to verify. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Route user lookups in InternalAdapter through getCurrentAdapter so they use the transaction-bound adapter. Prevents deadlocks when running inside runWithTransaction. <sup>Written for commit 74116c483a5fa8cdc2254fc804aea46df5898bf6. 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:48:19 -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#33137