WebAuthn recipe: thread the transaction connection through the remaining recipe bodies

Author: tamassolteszCreated Sep 28, 2026Updated Sep 28, 2026
Labelsagent-wip

Part of PLAN-018, Unit 4 (core-only). Full design: agent-plans PLAN-018. WebAuthN.updateUserEmail is already fixed (PR #1460); this ticket applies the same principle to the rest of the recipe.

Problem. WebAuthn resolves user-ids and reads primary users inside its transactions across register / account-linking / credential-update / recover-account. Those in-tx reads borrow a second connection from the same pool.

Fix (follow the #1460 pattern).

  • A live primary-user read inside a transaction (e.g. getPrimaryUserByWebauthNCredentialId) must run on the transaction connection via its _Transaction variant — getPrimaryUserByWebauthNCredentialId_Transaction ALREADY EXISTS on AuthRecipeSQLStorage, so no plugin-interface change is needed here. Do NOT hoist a live user read out of the transaction (it splits read and write across two transactions and opens a read-then-act gap).
  • The ONE thing that may be hoisted is the stable external->internal id translation (translateToInternalUserId -> getUserIdMapping), exactly as #1460 did for updateUserEmail — apply that same hoist to the other WebAuthn methods that resolve an id before any live read.

Acceptance.

  • No WebAuthn recipe transaction borrows a second pooled connection.
  • WebauthNAccountLinkingFlowTest, CredentialRegisterFlowTest, WebAuthNFlowTest, RecoverAccountFlowTest, UpdateEmailFlowTest pass with no nested-acquisition warning.
  • CHANGELOG line under the topmost unreleased section: Fix: WebAuthn recipe transactions resolved user records on a second pooled connection.
  • No version bump in the PR.

Plan: PLAN-018

Source: supertokens/supertokens-core