Skip to content

Sluggish Typescript performance #1252

@BjoernRave

Description

@BjoernRave

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Open cursor with a file where sth related to better-auth is used.

Current vs. Expected behavior

For some reason typescript is suuper slow when dealing with anything from better-auth.

Not sure if anyone else experiences the same, also not sure how to go about sth like that, maybe someone has an idea. Happy to provide more details.

What version of Better Auth are you using?

1.1.4

Provide environment information

MacOS
cursor

part of a turborepo/pnpm monorepo.


    "typescript": "5.7.2"
  "better-auth": "^1.1.14",

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

Types

Auth config (if applicable)

my init: 


import { prisma } from "@scoutello/db"
import { sendMail } from "@scoutello/mail"
import { betterAuth } from "better-auth"

import { prismaAdapter } from "better-auth/adapters/prisma"
import { bearer, emailOTP, organization } from "better-auth/plugins"

export const auth: any = betterAuth({
  appName: "Scoutello",
  database: prismaAdapter(prisma, {
    provider: "postgresql", // or "mysql", "postgresql", ...etc,
  }),
  session: {
    freshAge: 0,
  },
  emailVerification: {
    async sendVerificationEmail({ user, url }) {
      await sendMail({
        to: user.email,
        type: "verify-mail",
        variables: {
          verifyLink: url,
        },
        language: "de",
      })
    },
  },
  account: {
    accountLinking: {
      trustedProviders: ["google", "microsoft", "linkedin"],
    },
  },
  emailAndPassword: {
    enabled: true,
    async sendResetPassword({ user, url }) {
      await sendMail({
        to: user.email,
        type: "reset-password",
        variables: {
          resetLink: url,
          username: user.email,
        },
        language: "de",
      })
    },
  },
  socialProviders: {
    google: {
      clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || "",
      clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
    },
    microsoft: {
      clientId: process.env.MICROSOFT_CLIENT_ID || "",
      clientSecret: process.env.MICROSOFT_CLIENT_SECRET || "",
    },
    linkedin: {
      clientId: process.env.LINKEDIN_CLIENT_ID || "",
      clientSecret: process.env.LINKEDIN_CLIENT_SECRET || "",
    },
  },
  plugins: [
    organization({
      async sendInvitationEmail(data) {
        await sendMail({
          to: data.email,
          type: "invite-user",
          variables: {
            username: data.email,
            invitedByUsername: data.inviter.user.name,
            invitedByEmail: data.inviter.user.email,
            teamName: data.organization.name,
            inviteLink:
              process.env.NODE_ENV === "development"
                ? `http://localhost:3000/accept-invitation/${data.id}`
                : `${
                    process.env.BETTER_AUTH_URL ||
                    "https://demo.better-auth.com"
                  }/accept-invitation/${data.id}`,
          },
          language: "de",
        })
      },
    }),
    emailOTP({
      async sendVerificationOTP({ email, otp, type }) {
        await sendMail({
          to: email,
          type: "send-otp",
          variables: {
            otp,
            username: email,
          },
          language: "de",
        })
      },
    }),
    bearer(),
  ],
})


my client: 



import { Preferences } from "@capacitor/preferences"
import { emailOTPClient } from "better-auth/client/plugins"
import { createAuthClient } from "better-auth/react"
import { toast } from "sonner"
import { AUTH_TOKEN } from "@scoutello/shared/constants"
export const client = createAuthClient({
  plugins: [emailOTPClient()],
  fetchOptions: {
    onError(e) {
      if (e.error.status === 429) {
        toast.error("Too many requests. Please try again later.")
      }
    },
    auth: {
      type: "Bearer",
      token: () =>
        Preferences.get({ key: AUTH_TOKEN }).then((res) => res.value) || "", // get the token from localStorage
    },
  },
})

export const {
  signUp,
  signIn,
  signOut,
  useSession,
  organization,
  useListOrganizations,
  useActiveOrganization,
  emailOtp,
} = client

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglockedLocked conversations after being closed for 7 days

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions