#VS Code performance
10 messages · Page 1 of 1 (latest)
Hi @coarse bear. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
I'm sorry, but there is no specific information in the knowledge sources regarding a direct performance hit specifically from adding exactly "2 Convex Components." However, the knowledge sources do discuss general TypeScript performance issues and "infinite loading" states in large Convex projects.
If your TypeScript Intellisense is taking an excessive amount of time or seems to hang, it is likely due to how Convex relies on TypeScript's type inference. As codebases grow, this inference can become slow [Production > Project Configuration].
Recommended Solutions
- Enable Static Code Generation (Beta)
If you are experiencing language server performance issues, you can switch to static types. This significantly improves autocomplete and incremental typechecking performance by generating fixed versions of your API and data model instead of relying on real-time inference.
Add this to yourconvex.json:Note: This requires{ "$schema": "./node_modules/convex/schemas/convex.schema.json", "codegen": { "staticApi": true, "staticDataModel": true } }convex devto be running to update types, and you lose "jump-to-definition" functionality [Production > Project Configuration].
-
Check for "Excessive Deep Type Instantiation" (TS2589)
This error often occurs when a function returns the result of another Convex function (like actx.runQueryresult) without explicit typing, creating a circular type loop. To fix this, explicitly type your function return values or the variables receiving the data:// Explicitly typing the variable to break the inference loop const user: Doc<"users"> = await ctx.runQuery(internal.users.get, { id });This prevents the TypeScript server from "crashing out" or becoming sluggish [Discord support thread: Excessive Deep Type Instantiation (TS2589); Discord support thread: Type instantiation is excessively deep and possibly infinite.].
-
IDE Specific Troubleshooting
- Restart TypeScript Server: Use
Cmd + Shift + P(orCtrl + Shift + P) and select TypeScript: Restart TS Server [Discord support thread: No types in ide]. - Delete Generated Folder: Occasionally, deleting the
convex/_generatedfolder and lettingnpx convex devregenerate it can resolve stuck states [Discord support thread: Excessive Deep Type Instantiation (TS2589)].
- Restart TypeScript Server: Use
- Convex Version
Some users reported that the Convex CLI might hang during bundling in certain versions. If the "loading forever" refers to the CLI itself (e.g.,npx convex dev), ensure you are on the latest version or check if rolling back to1.25.0addresses the hang as a temporary workaround [Discord support thread: Issue:convex devhangs indefinitely on "Preparing Convex functions..." step].
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@coarse bear Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@bleak halo This is caused by agent.generateObject complaining about Type instantiation is excessively deep and possibly infinite.ts(2589)
Let me check the knowledge base for you again. One moment! :books:
I'm sorry, but the provided knowledge sources do not contain information about an agent.generateObject function. The knowledge sources explicitly mention that the "Type instantiation is excessively deep and possibly infinite (TS2589)" error in Convex typically occurs when there is circular type inference, particularly when calling and returning results from other Convex functions without explicit typing.
To resolve this error in the context of Convex, you can follow these strategies derived from the knowledge sources:
1. Explicitly Type Return Values
The most common cause is returning a value from ctx.runQuery, ctx.runMutation, or ctx.runAction directly. TypeScript struggles to infer these nested types. You should explicitly type the handler's return value or the variable capturing the result:
// Type the handler return value explicitly
export const myAction = action({
args: {},
handler: async (ctx): Promise<string> => {
const result = await ctx.runQuery(api.myFunctions.getSomething);
return result.name;
},
});
// OR type the result variable explicitly
export const myAction = action({
args: {},
handler: async (ctx) => {
const result: { name: string } = await ctx.runQuery(api.myFunctions.getSomething);
return result.name;
},
});
[Functions > Actions > The action constructor; Discord support thread: Type instantiation is excessively deep and possibly infinite.]
2. Avoid v.any() in Schemas
Several users found that using v.any() inside complex validators, such as v.record(v.string(), v.any()), triggered this specific error. Replacing v.any() with a more specific type (like v.string() or v.json()) often resolves the issue [Discord support thread: Type instantiation is excessively deep and possibly infinite.].
3. Use Static Code Generation
If the error persists across your project due to its size, you can enable static code generation. This stops the deep real-time inference that causes TS2589 by generating fixed types for your API [Production > Project Configuration; Discord support thread: Excessive Deep Type Instantiation (TS2589)].