[GH-ISSUE #1333] circular dependency error #8696

Closed
opened 2026-04-13 03:51:32 -05:00 by GiteaMirror · 8 comments
Owner

Originally created by @SOG-web on GitHub (Feb 2, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1333

Type instantiation is excessively deep and possibly infinite.

import { createAuthClient } from "better-auth/react";
import { phoneNumberClient } from "better-auth/client/plugins";
import { rlsClientPlugin } from "./rls-plugin/client";
export const authClient = createAuthClient({
  baseURL: `${process.env.NEXT_PUBLIC_API_ENDPOINT}/auth`,
  plugins: [rlsClientPlugin(), phoneNumberClient()],
});

export const { signIn, signUp, useSession, signOut } = createAuthClient();

Am running better-auth on two different nextjs application, I have 100% the same setup, but getting this error on one of the app

please any help would be great thanks

Originally created by @SOG-web on GitHub (Feb 2, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1333 `Type instantiation is excessively deep and possibly infinite.` ```ts import { createAuthClient } from "better-auth/react"; import { phoneNumberClient } from "better-auth/client/plugins"; import { rlsClientPlugin } from "./rls-plugin/client"; export const authClient = createAuthClient({ baseURL: `${process.env.NEXT_PUBLIC_API_ENDPOINT}/auth`, plugins: [rlsClientPlugin(), phoneNumberClient()], }); export const { signIn, signUp, useSession, signOut } = createAuthClient(); ``` Am running better-auth on two different nextjs application, I have 100% the same setup, but getting this error on one of the app please any help would be great thanks
GiteaMirror added the locked label 2026-04-13 03:51:32 -05:00
Author
Owner

@ping-maxwell commented on GitHub (Feb 10, 2025):

Are you using a monorepo with two next apps within?

<!-- gh-comment-id:2646869848 --> @ping-maxwell commented on GitHub (Feb 10, 2025): Are you using a monorepo with two next apps within?
Author
Owner

@madisonbullard commented on GitHub (Feb 13, 2025):

I'm seeing this as well, running better-auth in a monorepo, but its only used within 1 package in the monorepo currently.

EDIT: My issue ended up being fixed by rolling back zod from 3.24.2 to 3.24.1.

I'm not sure this is the case, but I think it might've been a version conflict with the zod version that ships with better-fetch

<!-- gh-comment-id:2655438150 --> @madisonbullard commented on GitHub (Feb 13, 2025): I'm seeing this as well, running better-auth in a monorepo, but its only used within 1 package in the monorepo currently. EDIT: My issue ended up being fixed by rolling back `zod` from 3.24.2 to 3.24.1. I'm not sure this is the case, but I think it might've been a version conflict with the zod version that ships with `better-fetch`
Author
Owner

@SOG-web commented on GitHub (Feb 13, 2025):

Have been able to solve it, the error is caused by ts config. I will send the fix in some hours time

<!-- gh-comment-id:2656449234 --> @SOG-web commented on GitHub (Feb 13, 2025): Have been able to solve it, the error is caused by ts config. I will send the fix in some hours time
Author
Owner

@benjamindell commented on GitHub (Feb 14, 2025):

Im also seeing this error. If you're able to share the fix, i'd hugely appreciate it. I'm unable to deploy my code at the moment :(

<!-- gh-comment-id:2658674295 --> @benjamindell commented on GitHub (Feb 14, 2025): Im also seeing this error. If you're able to share the fix, i'd hugely appreciate it. I'm unable to deploy my code at the moment :(
Author
Owner

@SOG-web commented on GitHub (Feb 14, 2025):

Im also seeing this error. If you're able to share the fix, i'd hugely appreciate it. I'm unable to deploy my code at the moment :(

Try turning on strict in your ts config

<!-- gh-comment-id:2659755537 --> @SOG-web commented on GitHub (Feb 14, 2025): > Im also seeing this error. If you're able to share the fix, i'd hugely appreciate it. I'm unable to deploy my code at the moment :( Try turning on strict in your ts config
Author
Owner

@benjamindell commented on GitHub (Feb 14, 2025):

Ah thanks but I already had that set to true. Im still getting the issue - it's grinding my entire project / VScode interface to a halt.

<!-- gh-comment-id:2659792167 --> @benjamindell commented on GitHub (Feb 14, 2025): Ah thanks but I already had that set to true. Im still getting the issue - it's grinding my entire project / VScode interface to a halt.
Author
Owner

@SOG-web commented on GitHub (Feb 16, 2025):

this is my ts-config

{
  "compilerOptions": {
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "noImplicitAny": false,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}
<!-- gh-comment-id:2661663438 --> @SOG-web commented on GitHub (Feb 16, 2025): this is my ts-config ```json { "compilerOptions": { "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true, "noImplicitAny": false, "plugins": [ { "name": "next" } ], "paths": { "@/*": ["./src/*"] } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] } ```
Author
Owner

@benjamindell commented on GitHub (Feb 17, 2025):

This issue is now entirely resolved for me - the fix for me was upgrading to the 1.2 better-auth beta.

<!-- gh-comment-id:2662193259 --> @benjamindell commented on GitHub (Feb 17, 2025): This issue is now entirely resolved for me - the fix for me was upgrading to the 1.2 better-auth beta.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8696