djbalin
djbalin•4mo ago

[Convex Auth]: convexAuth() causes "Type instantiation is excessively deep and possibly infinite."

We get the Type instantiation is excessively deep and possibly infinite. error on our api object whenever we export our Convex auth stuff from auth.ts, e.g. with this simple example:
import { convexAuth } from '@convex-dev/auth/server';
import { Password } from '@convex-dev/auth/providers/Password';

export const { auth, signIn, signOut, store } = convexAuth({
providers: [Password],
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});
import { convexAuth } from '@convex-dev/auth/server';
import { Password } from '@convex-dev/auth/providers/Password';

export const { auth, signIn, signOut, store } = convexAuth({
providers: [Password],
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});
If we remove export from the above (such that it does not occur in our Convex generated files), our api type instantiation is not excessively deep.
2 Replies
djbalin
djbalinOP•3mo ago
We are still experiencing this issue. If we comment out our auth.ts file, the excessively deep-warning disappears. Any ideas @Michal Srb or @sshader ? Thanks 🌞
sshader
sshader•3mo ago
As a workaround, you can always add some type casts or explicit type annotations. I'm not sure what's causing this type error since I haven't seen it in other projects with Convex Auth. E.g.
const convexAuthFunctions: any = convexAuth({...})
export const { auth, signIn, signOut, store } = convexAuthFunctions
const convexAuthFunctions: any = convexAuth({...})
export const { auth, signIn, signOut, store } = convexAuthFunctions
(or add explicit type annotations for the things you care about like, auth) Curious if you're able to narrow down the problem by seeing which exported type is problematic