[PR #5221] [MERGED] fix(magic-link): dont trigger session refresh on sign-in #5862

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5221
Author: @ping-maxwell
Created: 10/10/2025
Status: Merged
Merged: 11/10/2025
Merged by: @Bekacru

Base: canaryHead: fix/magic-link-sign-in-shouldnt-refresh-session


📝 Commits (10+)

  • e737445 fix(magic-link): dont trigger session refresh on sign-in
  • 64c05d1 Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session
  • fe1a3cf Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session
  • 4421a04 Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session
  • 879acc7 Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session
  • c40672a Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session
  • 409732b Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session
  • c7ae5bb Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session
  • a52e5fb Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session
  • bf364dc Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session

📊 Changes

5 files changed (+23 additions, -7 deletions)

View changed files

📝 packages/better-auth/src/client/config.ts (+6 -5)
📝 packages/better-auth/src/plugins/anonymous/client.ts (+6 -0)
📝 packages/better-auth/src/plugins/email-otp/client.ts (+2 -1)
📝 packages/better-auth/src/plugins/phone-number/client.ts (+3 -1)
📝 packages/better-auth/src/plugins/username/client.ts (+6 -0)

📄 Description

the magic-link sign-in endpoint doesn't actually sign you in, it's there to send an email for the end user to sign-in via the URL contained in said email.

we automatically trigger a session refresh when the path starts with /sign-in, however in this case since the session doesn't actually refresh it doesn't make sense to trigger all useSession hooks to go into isPending.

closes: https://github.com/better-auth/better-auth/issues/4357
linear: https://linear.app/better-auth/issue/ENG-283/fix-magic-link-shouldnt-refresh-usesession-during-sign-in-endpoint


Summary by cubic

Stop triggering session refresh on the /sign-in/magic-link endpoint so useSession doesn’t go into isPending when we’re only sending the magic link email (ENG-283). Move session refresh signals to plugin-specific sign-in endpoints for accurate updates.

  • Bug Fixes
    • Narrowed $sessionSignal matcher in core to exact paths (e.g., /sign-in/email, /sign-up/email), excluding /sign-in/magic-link.
    • Added plugin atomListeners to trigger $sessionSignal on real sign-in flows: /sign-in/anonymous, /sign-in/email-otp, /sign-in/phone-number, /sign-in/username.

Written for commit fe39f86ec5. Summary will update automatically 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/5221 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 10/10/2025 **Status:** ✅ Merged **Merged:** 11/10/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/magic-link-sign-in-shouldnt-refresh-session` --- ### 📝 Commits (10+) - [`e737445`](https://github.com/better-auth/better-auth/commit/e7374453c681edb09ee0aba963f5ace1cdb6c48d) fix(magic-link): dont trigger session refresh on sign-in - [`64c05d1`](https://github.com/better-auth/better-auth/commit/64c05d102aa69057ad058b370e4857051816f0ad) Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session - [`fe1a3cf`](https://github.com/better-auth/better-auth/commit/fe1a3cf25a4b7c63662a243ee90c08076b0857f5) Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session - [`4421a04`](https://github.com/better-auth/better-auth/commit/4421a04ad4dc34902e784a7f3db678e963ac8ea9) Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session - [`879acc7`](https://github.com/better-auth/better-auth/commit/879acc72101bc8a81997e3960c32f51a2592402a) Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session - [`c40672a`](https://github.com/better-auth/better-auth/commit/c40672aee102b1213bd92ab264b5b1579e72ae8e) Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session - [`409732b`](https://github.com/better-auth/better-auth/commit/409732b2a7780a1faae739bdc9554fb9e8729bc7) Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session - [`c7ae5bb`](https://github.com/better-auth/better-auth/commit/c7ae5bb2b1aabadd7e1cc206cbcae4c4ed7245a7) Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session - [`a52e5fb`](https://github.com/better-auth/better-auth/commit/a52e5fb13a1a2634dd778e97192da35358d60e98) Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session - [`bf364dc`](https://github.com/better-auth/better-auth/commit/bf364dc812d8a990975b679bab5f7aedb8bc6924) Merge branch 'canary' into fix/magic-link-sign-in-shouldnt-refresh-session ### 📊 Changes **5 files changed** (+23 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/config.ts` (+6 -5) 📝 `packages/better-auth/src/plugins/anonymous/client.ts` (+6 -0) 📝 `packages/better-auth/src/plugins/email-otp/client.ts` (+2 -1) 📝 `packages/better-auth/src/plugins/phone-number/client.ts` (+3 -1) 📝 `packages/better-auth/src/plugins/username/client.ts` (+6 -0) </details> ### 📄 Description the magic-link sign-in endpoint doesn't actually sign you in, it's there to send an email for the end user to sign-in via the URL contained in said email. we automatically trigger a session refresh when the path starts with `/sign-in`, however in this case since the session doesn't actually refresh it doesn't make sense to trigger all useSession hooks to go into `isPending`. closes: https://github.com/better-auth/better-auth/issues/4357 linear: https://linear.app/better-auth/issue/ENG-283/fix-magic-link-shouldnt-refresh-usesession-during-sign-in-endpoint <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Stop triggering session refresh on the /sign-in/magic-link endpoint so useSession doesn’t go into isPending when we’re only sending the magic link email (ENG-283). Move session refresh signals to plugin-specific sign-in endpoints for accurate updates. - **Bug Fixes** - Narrowed $sessionSignal matcher in core to exact paths (e.g., /sign-in/email, /sign-up/email), excluding /sign-in/magic-link. - Added plugin atomListeners to trigger $sessionSignal on real sign-in flows: /sign-in/anonymous, /sign-in/email-otp, /sign-in/phone-number, /sign-in/username. <sup>Written for commit fe39f86ec5c4fdcf54d1d46675994306dc86b1bf. Summary will update automatically 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-03-13 12:39:24 -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#5862