Type instantiation is excessively deep and possibly infinite.
I honestly can't understand the reason for this error... can you help me? It works but only the build doesn't work.

39 Replies
intresting, mind sharing both your root tsconfig and the one in the /convex folder?
Also, this can be caused by an unrelated
ctx.runQuery/runMutation/runAction
in a different file. If a function uses any of these and returns the result or any part of the result without an explicit type, you can get this error in seemingly random files. (Not actually random, but it can seem that way). More here: https://docs.convex.dev/functions/actions#dealing-with-circular-type-inferenceconvex\tsconfig.json:
tsconfig.json:
its the tsconfig
try this, does it casue the same issues, I'm talking about the one in the root folder directory:
this is a less strict one, and doesn't specify target, which might be the case here
This change will force me to change the entire project

But the same error still appears

keep the src route then and remove the target only?
But the error remains :/
I don't think this is the problem anymore

oh..
do you have the convex folder as features?
https://docs.convex.dev/functions/actions#dealing-with-circular-type-inference
Maybe that's the problem, right? From what I've been reading
Actions | Convex Developer Hub
Call third-party services and external APIs from Convex
This doesn't happen on all platforms, the project is huge, it only appears on some APIs, and sometimes it's random..
it mght be.. which is still weird
can you hover over api and take a screenshot/copy paste the type?
It's strange because it doesn't happen in all files, and as I said, there are no errors, everything works perfectly.
yes!
convex_generated\api.d.ts - this?
that should do!
for that particular query, are you using ctx.runQuery, ctx.runMutation etc?
check:
I would grep the project for
ctx.run
to see where it's being used
Doesn't have to be in the same function
I've had times where my entire project wouldn't generate at allthe only fix occurring to google is to cast type, try passing a type in the query itself, say
if that didn't work, I don't know what could possibly be the issue tbh
But it exists and works perfectly

But it's not deploying because of the error right
Or did you deploy with typechecking off
// @ts-ignore :classic:
This is what I use but I would like to understand the reason sincerely 😂
Ah
yeah get rid of those
Your OP was about a different function, is there a reason the focus is on the linked accounts function now?
I asked him, because I wondered if it was because of an internal function somewhere that might be causign it
ah because he posted the image of the error in that function I see it now
No, but like I said, this "shitty" error keeps popping up in various files sometimes and it annoys me because everything is working 😂
You have to search for instances of ctx.run* to chase this down
I'm new to Convex and I'm migrating my project to Convex because I confess I fell in love with it.
It's the only way.
Okay, I'll look into this properly
Thank you very much for your help both of you
I had a serious problem with self-hosted
I posted it a few weeks ago but they didn't help me.
Because when I migrate the main project to convex, I will have more than 500 users using this simultaneously during the day
Did you see this response: https://discord.com/channels/1019350475847499849/1216859935288201296/1407035237866668133
Finding this cause I had the same error and thought my findings might help others.
After setting return types on everything the issue still wasn't resolved. I eventually started removing pieces one by one and found this was the culprit:
TypeScript didn't like the
v.any()
as the second parameter to v.record
. However, there was no warning/error associated with this line. I just discovered that changing the type or removing this arg completely resolved the infinite depth error.
LLMs really like any
... 😒Interesting, using v.any() should work okay for records. There were no other compounding factors?