MagicLink Verify ReferenceError #2180

Closed
opened 2026-03-13 09:32:20 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @PamMarie on GitHub (Oct 22, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Install the MagicLink plugin
  2. Request a MagicLink via email
  3. Attempt to access the verify route to complete sign-in

Current vs. Expected behavior

Expected behaviour: User is verified and signs in

Current behaviour:

ERROR [Better Auth]: ReferenceError ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor at Generator.next (<anonymous>)
SERVER_ERROR: ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor at Generator.next (<anonymous>)

This happens both when manually verifying through auth.api.magicLinkVerify and when using better-auth's api/auth/verify default.

What version of Better Auth are you using?

1.3.27

System info

{
  "system": {
    "platform": "linux",
    "arch": "arm64",
    "version": "#1 SMP Fri Nov 29 17:22:03 UTC 2024",
    "release": "6.10.14-linuxkit",
    "cpuCount": 10,
    "cpuModel": "unknown",
    "totalMemory": "15.60 GB",
    "freeMemory": "11.58 GB"
  },
  "node": {
    "version": "v22.13.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.2"
  },
  "frameworks": [
    {
      "name": "next",
      "version": "15.4.7"
    },
    {
      "name": "react",
      "version": "19.1.1"
    },
    {
      "name": "express",
      "version": "^4.21.0"
    }
  ],
  "databases": [
    {
      "name": "pg",
      "version": "^8.5.1"
    }
  ],
  "betterAuth": {
    "version": "1.3.27",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { magicLink } from "better-auth/plugins";
export const auth = betterAuth({
    plugins: [
        magicLink({
            sendMagicLink: async ({ email, token, url }, request) => {
                // send email to user
            }
        })
    ]
})

Additional context

No response

Originally created by @PamMarie on GitHub (Oct 22, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Install the [MagicLink plugin](https://www.better-auth.com/docs/plugins/magic-link#installation) 2. Request a MagicLink via email 3. Attempt to access the verify route to complete sign-in ### Current vs. Expected behavior Expected behaviour: User is verified and signs in Current behaviour: ``` ERROR [Better Auth]: ReferenceError ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor at Generator.next (<anonymous>) SERVER_ERROR: ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor at Generator.next (<anonymous>) ``` This happens both when manually verifying through `auth.api.magicLinkVerify` and when using better-auth's `api/auth/verify` default. ### What version of Better Auth are you using? 1.3.27 ### System info ```bash { "system": { "platform": "linux", "arch": "arm64", "version": "#1 SMP Fri Nov 29 17:22:03 UTC 2024", "release": "6.10.14-linuxkit", "cpuCount": 10, "cpuModel": "unknown", "totalMemory": "15.60 GB", "freeMemory": "11.58 GB" }, "node": { "version": "v22.13.1", "env": "development" }, "packageManager": { "name": "npm", "version": "10.9.2" }, "frameworks": [ { "name": "next", "version": "15.4.7" }, { "name": "react", "version": "19.1.1" }, { "name": "express", "version": "^4.21.0" } ], "databases": [ { "name": "pg", "version": "^8.5.1" } ], "betterAuth": { "version": "1.3.27", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { magicLink } from "better-auth/plugins"; export const auth = betterAuth({ plugins: [ magicLink({ sendMagicLink: async ({ email, token, url }, request) => { // send email to user } }) ] }) ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 09:32:20 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 22, 2025):

Hi @PamMarie! I'm Dosu and I’m helping the better-auth team.

This ReferenceError is a known issue in Better Auth v1.3.27, especially with MagicLink verification. It's likely caused by a bug in the plugin or core related to class inheritance or async handling. There's an open pull request that may fix this, but it's not merged yet and the blocker is unclear [source]. Users have reported that type inference for the user object also breaks in this version, which may be related.

For now, make sure your Better Auth config explicitly enables the MagicLink plugin and includes all required options (like sendMagicLink). Defensive checks in your hooks and session logic can help avoid related runtime errors. If you need a workaround, try downgrading to a previous stable version or monitor the status of PR #3368 for a fix. Adding logging in your verification hooks and session callbacks can help pinpoint where the user object or session becomes undefined or incomplete [source].

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 22, 2025): <!-- Greeting --> Hi @PamMarie! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This ReferenceError is a known issue in Better Auth v1.3.27, especially with MagicLink verification. It's likely caused by a bug in the plugin or core related to class inheritance or async handling. There's an open pull request that may fix this, but it's not merged yet and the blocker is unclear [[source](https://github.com/better-auth/better-auth/issues/5291)]. Users have reported that type inference for the user object also breaks in this version, which may be related. For now, make sure your Better Auth config explicitly enables the MagicLink plugin and includes all required options (like `sendMagicLink`). Defensive checks in your hooks and session logic can help avoid related runtime errors. If you need a workaround, try downgrading to a previous stable version or monitor the status of PR #3368 for a fix. Adding logging in your verification hooks and session callbacks can help pinpoint where the user object or session becomes undefined or incomplete [[source](https://github.com/better-auth/better-auth/issues/4458)]. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/81d0b9a3-fdc8-4f17-b62b-ceadf13c9436?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/81d0b9a3-fdc8-4f17-b62b-ceadf13c9436?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/81d0b9a3-fdc8-4f17-b62b-ceadf13c9436?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/81d0b9a3-fdc8-4f17-b62b-ceadf13c9436?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/81d0b9a3-fdc8-4f17-b62b-ceadf13c9436?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/81d0b9a3-fdc8-4f17-b62b-ceadf13c9436?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/81d0b9a3-fdc8-4f17-b62b-ceadf13c9436?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5483)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2180