TypeScript server slow - CPU goes up to 160% when waiting for the autocompletion
See original GitHub issueDoes this issue occur when all extensions are disabled?: Yes
- VS Code Version: Version: 1.61.0-insider (Universal)
- Operating system:
- macOS 11.5.2
Steps to Reproduce:
- Got a simple Next.js application with
react-hook-form
installed (not sure if that matters), trying to get autocompletion on theiruseForm
hook. Shows me āLoadingā¦ā, takes a couple seconds, and CPU jumps up to 160% in the Activity Monitor. (I also got autocomplete issues on other places, not only on their hook, just used that as an example). - Originally got this issue in the normal version. Switched over to the Insiders version and still got this issue. The project isnāt large and my CPU usage only spikes when I use features from the TypeScript server. I already installed the typescript@next extension and made sure that VSCode uses that version, unfortunately the same issue.
Even saving ts/tsx files can take a couple seconds. And whenever I try to use something that it is not imported, it shows the red line under it. However, when I do import it, it takes a couple seconds before VSCode notices it so the ānot importedā error stays there for quite a long time and my CPU usage spikes.
Edit: I recorded a small video that shows when my CPU usage spikes and that VSCode randomly had trouble with importing a few things and that it takes a couple of seconds before it noticed that I already imported it. Also the autocomplete takes a couple of seconds and the CPU usage also spikes on that.
(I am not too sure why VSCode didnāt automatically import the first two hooks, I needed to manually click on them and then it let me import them, as you can see in the video.)
When using the normal VSCode (not the Insiders version), the autocomplete is even slower and the CPU usage spikes up to 180% (even though all extensions are disabled). I noticed that the fans were going crazy when I was waiting for the autocompletion.
In the Process Explorer, electron_node tsserver.js
is the one that spikes.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:8 (4 by maintainers)
@andrewbranch Just tried to put that setting to false in VSCode, unfortunately it doesnāt seem to be effective for me.
However, as soon as I remove the package that has this
ajv
package, my autocompletion feels much faster than before. I think the issue is also not there when I just donāt import anything from that specific package.It maybe has something to do with
zod
, Iāve had seen multiple comments about that crashing TS servers. My issue is completely gone as soon as I remove that package. Iāll try to use 4.2 of TypeScript to see if that solved anything.@andrewbranch Thanks a lot for your quick response! Totally makes sense. I will look into whatās actually happening and keep you updated.