CPU High 🔥 #60
Replies: 5 comments 3 replies
-
Meeting the same problem. (I have only 5 models.) I think it is caused by typescript language server. Because when I type, the typescript prompt is very slow. |
Beta Was this translation helpful? Give feedback.
-
It's something Typescript cause when there are many files. Other generators for Prisma have suffered of this issue before and still. I'm thinking of providing an option to export all routers and schemas in a single file(or two). That should fix the problem I guess. Would that be useful to you? |
Beta Was this translation helpful? Give feedback.
-
I don't know typescript in depth enough to know how it works under the hood so I can't say if using one file versus multiple will fix the problem. Do you think so? Maybe we should get some inspiration from Prisma itself. For example, why does it create the type file in the node_modules? |
Beta Was this translation helpful? Give feedback.
-
I don't think this is doable. The issue come from Zod itself. Zod infer a lot to type object. Those type object created by Zod are dynamically made with the schema. If you are writting Zod schemas, it won't affect you much because you are only launching the LSP for that definition your working on. Because it's hundred or thousand of schemas you generate in one go with this generator. You overload the Typescript's LSP and it try to type every schemas at the same time. In fact, I would expect that if the generator wouldn't delete the file just before generating it again, it would be less CPU heavy. Typescript wouldn't have to analyse every definition, because he would know that this definition hasn't changed from the last time he analyse it. Tbh, I don't know if this would help. File would still be overwritten which would trigger Typescript to analyse the file. My solution is to comment the generator when I don't want to update Zod/tRPC and uncomment when I need it. |
Beta Was this translation helpful? Give feedback.
-
I just asked the same question in #69 this is really killing the DX :( |
Beta Was this translation helpful? Give feedback.
-
I just followed the setup steps successfully and then my CPU usage (VSCode Code Help, which does the Intellisense) is going beyond 100% which basically breaks the VSCode usability and typescript.
I have 10 models in my Prisma schema (not much I think). Besides I have a 2021 Macbook Pro M1 Pro 16GB ram.
So I suppo I'm missing something.
Can someone help?
Beta Was this translation helpful? Give feedback.
All reactions