Type instantiation is excessively deep and possibly infinite
G'day! For past two days i'm thinking how to solve an issue with queries and stuff like that.
The issue is when I'm using useQuery. or anything other, i'm getting error with api with a message called Type instantiation is excessively deep and possibly infinite.
Any ideas how to fix it?
12 Replies
Sounds frustrating to have this problem for several days! This issue is usually caused by a syntax error in a Convex function or a Convex action that uses ctx.runMutation, ctx.runAction, or ctx.runQuery for type inference.
okay, so maybe I can return to 1.2.1? Might help i guess
No, changing the version of Convex shouldn't help. This is an issue with your queries, mutations, or actions in your
convex/
folder.well, my functions are not problem. For example: which does not have any problems
If you open up convex/generated/api.d.ts are any of the imports broken? (underlined in red)
no, i don't see any
Unfortunately an error in one of these functions can cause this problem in all of them — so you need to check them all
could you share your code?
feel free to DM
With a lot (a lot) of code this might not be caused by errors. To get around it type annotate the return type of your functions (especial actions using runQuery/runMutation). But wrong imports/empty files inside
convex
are more likely.Yea this happened to me recently. Looking through my notes I had a bad import statement in one of my convex query files.
We looked at this together, turns out it was some empty files in convex/
empty files aren't valid modules so TypeScript was sad.
We'll look at improving the error message here.
I was thinking maybe there's some rules that can be disabled for a compiler?
Like some eslint errors
I ran into same issue and don't have idea how to fix it no empty files in convex dir