Joshowaaah!
Joshowaaah!2mo ago

Very Fun Instance of Type instantiation is excessively deep and possibly infinite.ts(2589)

Encountering this error, the following is what I have done to try to resolve it. I have read this: https://docs.convex.dev/functions/actions#dealing-with-circular-type-inference so I ensured every single query, action, and mutation, internal ones too, have both a returns, and a typed return for the handler. EX
export const meFromIntegration = query({
args: { integrationId: v.string() },
returns: v.union(
v.object({
name: v.optional(v.string()),
email: v.optional(v.string()),
image: v.optional(v.string()),
timezone: v.optional(v.string()),
languageCode: v.optional(v.string()),
}),
v.null(),
),
handler: async (
ctx,
args,
): Promise<{
name: string;
email: string;
image: string;
timezone: string;
languageCode: LanguageCode;
} | null> => {
export const meFromIntegration = query({
args: { integrationId: v.string() },
returns: v.union(
v.object({
name: v.optional(v.string()),
email: v.optional(v.string()),
image: v.optional(v.string()),
timezone: v.optional(v.string()),
languageCode: v.optional(v.string()),
}),
v.null(),
),
handler: async (
ctx,
args,
): Promise<{
name: string;
email: string;
image: string;
timezone: string;
languageCode: LanguageCode;
} | null> => {
didnt fix it. So I kept looking around at other threads. Saw one mentioning it could have to do with Doc<>, so I removed all instances of Doc. Okay, Not it. Also found something referencing v.any(), so now I dont use v.any(), no dice. Okay so it said it had to do with ctx.run* not having a type. So I commented out every instance of ctx.run*, runMutation, runQuery, whatever. Still Not it. No idea whats left to try.
2 Replies
Convex Bot
Convex Bot2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart2mo ago
returns isn't going to do anything here, circular inference is cut off either inside the handler or via function return type of the handler itself. If you use anything that relies on inference via Convex generated types, eg., Doc, Id, you're still in the circle.

Did you find this page helpful?