[PR #5096] [MERGED] fix(passkey): atom listeners not working #5772

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5096
Author: @ping-maxwell
Created: 10/5/2025
Status: Merged
Merged: 10/7/2025
Merged by: @himself65

Base: canaryHead: fix/passkey-atoms


📝 Commits (8)

  • 06cf803 fix(passkey): atom listeners not working
  • e1aaa00 chore: revert telemetry temp change
  • 05533f9 Merge branch 'canary' into fix/passkey-atoms
  • 26e0897 Merge branch 'canary' into fix/passkey-atoms
  • 48d102a Merge branch 'canary' into fix/passkey-atoms
  • 4d9c541 Merge branch 'canary' into fix/passkey-atoms
  • 568a249 chore: cleanup
  • 2793ede Merge branch 'canary' into fix/passkey-atoms

📊 Changes

2 files changed (+29 additions, -16 deletions)

View changed files

📝 packages/better-auth/src/client/proxy.ts (+15 -12)
📝 packages/better-auth/src/plugins/passkey/client.ts (+14 -4)

📄 Description

closes: https://github.com/better-auth/better-auth/issues/858
linear: https://linear.app/better-auth/issue/ENG-17/fix-usesession-does-not-update-after-passkey-authentication

This PR doesn't just fix the passkey bugs with Atom listeners, but also addresses some major flaws in the client atom listeners.

Fixes

  • the client path proxy doesn't find all successful atomListeners.matcher cases, instead it only finds 1 matched atomLister, and calls that. This means if multiple atom listeners are trying to watch the same path (e.g. /sign-out) only the first plugin which passes the matcher for that path will be called, all other plugins will be ignored.
  • While debugging this issue, I noticed the atomListener for the passkey plugin was using the signal _listPasskeys instead of $listPasskeys. Not sure if that's intentional or not, but I'm pretty sure it's been like this for months now. So everyone's usePasskeyList hook only partially work. (I say partially because there is 1 case where we forcefully call the listener, but besides that no cases will call the listPasskeys hook)
  • Initially, this PR was made to resolve not updating the session when passkey sign in was successful, however along the way I also added other fixes specific to passkey atoms:
    • fixed /sign-out not re-triggering the listPasskeys atom.
    • And lastly - the reason this PR was made in the first place - fixed session not updating when passkey sign in succeeded.

Summary by cubic

Fixes atom listeners for passkey flows so the UI refreshes the passkey list and session state after registration, authentication, update, delete, and sign-out.

  • Bug Fixes
    • Proxy now triggers all matching atom listeners (not just the first), with guards for missing atoms and a safe async toggle to prevent race conditions.
    • Passkey client corrects signal name to "$listPasskeys", adds "$sessionSignal" listener, includes "/sign-out" and "/passkey/verify-authentication" routes, and notifies both signals after passkey sign-in.

🔄 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/5096 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 10/5/2025 **Status:** ✅ Merged **Merged:** 10/7/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/passkey-atoms` --- ### 📝 Commits (8) - [`06cf803`](https://github.com/better-auth/better-auth/commit/06cf803c9880f2e73b1f1edefb1242f61a175453) fix(passkey): atom listeners not working - [`e1aaa00`](https://github.com/better-auth/better-auth/commit/e1aaa006cbc261bdab3a35e3c10fbd0ee9a63e1d) chore: revert telemetry temp change - [`05533f9`](https://github.com/better-auth/better-auth/commit/05533f95786c19f810adba076949df3dfeea97a7) Merge branch 'canary' into fix/passkey-atoms - [`26e0897`](https://github.com/better-auth/better-auth/commit/26e0897c8ba2b38c8ef13aea912da7a594b73bb9) Merge branch 'canary' into fix/passkey-atoms - [`48d102a`](https://github.com/better-auth/better-auth/commit/48d102a320fbb89d6121d0961acc215cf64817e4) Merge branch 'canary' into fix/passkey-atoms - [`4d9c541`](https://github.com/better-auth/better-auth/commit/4d9c541f493406f26a703a36d9a6c7e1a50dbd2c) Merge branch 'canary' into fix/passkey-atoms - [`568a249`](https://github.com/better-auth/better-auth/commit/568a249ead5bb707ef0c59bee5223766589e5f55) chore: cleanup - [`2793ede`](https://github.com/better-auth/better-auth/commit/2793ede8105e24803c281a78514fb875c1905dac) Merge branch 'canary' into fix/passkey-atoms ### 📊 Changes **2 files changed** (+29 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/proxy.ts` (+15 -12) 📝 `packages/better-auth/src/plugins/passkey/client.ts` (+14 -4) </details> ### 📄 Description closes: https://github.com/better-auth/better-auth/issues/858 linear: https://linear.app/better-auth/issue/ENG-17/fix-usesession-does-not-update-after-passkey-authentication This PR doesn't just fix the passkey bugs with Atom listeners, but also addresses some major flaws in the client atom listeners. ## Fixes * the client path proxy doesn't find all successful `atomListeners.matcher` cases, instead it only finds 1 matched atomLister, and calls that. This means if multiple atom listeners are trying to watch the same path (e.g. `/sign-out`) only the first plugin which passes the matcher for that path will be called, all other plugins will be ignored. * While debugging this issue, I noticed the atomListener for the passkey plugin was using the signal `_listPasskeys` instead of `$listPasskeys`. Not sure if that's intentional or not, but I'm pretty sure it's been like this for months now. So everyone's `usePasskeyList` hook only partially work. (I say partially because there is 1 case where we forcefully call the listener, but besides that no cases will call the listPasskeys hook) * Initially, this PR was made to resolve not updating the session when passkey sign in was successful, however along the way I also added other fixes specific to passkey atoms: * fixed `/sign-out` not re-triggering the `listPasskeys` atom. * And lastly - the reason this PR was made in the first place - fixed session not updating when passkey sign in succeeded. <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fixes atom listeners for passkey flows so the UI refreshes the passkey list and session state after registration, authentication, update, delete, and sign-out. - **Bug Fixes** - Proxy now triggers all matching atom listeners (not just the first), with guards for missing atoms and a safe async toggle to prevent race conditions. - Passkey client corrects signal name to "$listPasskeys", adds "$sessionSignal" listener, includes "/sign-out" and "/passkey/verify-authentication" routes, and notifies both signals after passkey sign-in. <!-- 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:35:18 -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#5772