Vscode: TSServer is using 100% CPU on VS Code 1.33

Created on 7 Apr 2019  ·  44Comments  ·  Source: microsoft/vscode

Issue Type: Performance Issue

Code helper is using 100% of my cpu. All plugins are disabled and no big files (or large amounts) are present in my workspace.

VS Code version: Code 1.33.0 (0dd516dd412d42323fc3464531b1c715d51c4c1a, 2019-04-04T15:11:32.076Z)
OS version: Darwin x64 18.5.0


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)|
|GPU Status|2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled|
|Load (avg)|3, 12, 8|
|Memory (System)|16.00GB (3.61GB free)|
|Process Argv|--disable-extensions .|
|Screen Reader|no|
|VM|0%|


Process Info

CPU %   Mem MB     PID  Process
   16       98    3250  code main
    0       82    3257     gpu-process
    0      246    3324     window (TravelSearch.jsx — bakalauras-ui)
    0       66    3348       extensionHost
  102      426    3357         electron_node tsserver.js 
    0       66    3371           electron_node typingsInstaller.js typesMap.js 
    0       49    3350       watcherService
    0       98    3356     shared-process
    0       82    3950     window (Issue Reporter)
    0        0    3964     /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=



Workspace Info

|  Window (TravelSearch.jsx — bakalauras-ui)
|    Folder (bakalauras-ui): 29 files
|      File types: jsx(14) json(3) js(3) lock(1) development(1) log(1)
|                  production(1) ico(1) html(1) md(1)
|      Conf files: package.json(1);


Extensions disabled

Most helpful comment

I checked /home/(your username)/.cache/typescript/, however it was empty. I deleted the TS cache in /Users/(username)/Library/Caches/typescript, the cpu usage has dropped since then.

All 44 comments

This bug is not present in the insiders build.

Please try deleting ATA cache folder (below) and see if that fixes the problem. We had a large performance regression caused by a combinatorially-explosive file being uploaded to DefinitelyTyped and an unpatched version of it might still be getting loaded. Thanks and please @ me if that doesn't solve your problem!

(Windows)

C:\Users\(your username)\AppData\Local\Microsoft\TypeScript\

(Mac/Linux)

/home/(your username)/.cache/typescript/

I checked /home/(your username)/.cache/typescript/, however it was empty. I deleted the TS cache in /Users/(username)/Library/Caches/typescript, the cpu usage has dropped since then.

@vasilev-alex @b02k5 @kylecorbelli @goodoldneon @Robfz @maxsbelt @ra50 @lewismorris can you try the above fix and let us know the results? Thanks!

Didn't work for me. Code helper is still using about 100% CPU

@vasilev-alex do you have a project (or subset of a project) that reliably reproduces the problem that you can share with us?

@RyanCavanaugh it did work for me!

@RyanCavanaugh Just a create-react-app project with styled components. Check it out here https://github.com/vasilev-alex/react-playground

Mine is a TypeScript create-react-app project with styled components. I deleted all of /Users/(username)/Library/Caches/typescript and there wasn't even a /home/(your username)/.cache/typescript/ directory on my machine.

Verdict: the above fix did not work 😭

@kylecorbelli the prescribed fix is for JavaScript users. If you are using TypeScript, you'll need to update your project's dependency on @types/styled-components. Apparently there are still issues with TypeScript 3.4 in general, so simply updating the dependency won't fully fix things.

the solution from @RyanCavanaugh works for me in macOS

I've had the same problem and narrowed it down to the backticks used in a styled component

const TestStyledComp = styled.div`
   color: pink;
`

I have a basic setup here https://github.com/andrewcodes404/styledcomp-vscode-error/ which works fine until I uncomment the the styled component and then the vs code helper use all my CPU and vscode won't work properly and i get code --status

 102       426    3357         electron_node tsserver.js 

I have used @dziugasmeskauskas solution deleting the cache, /Users/(username)/Library/Caches/typescript it has helped a little but still slowing things down, doesn't feel very stable still gets peaks of electron_node cli.js

@DanielRosenwasser should i be using a different version of typescript?

I got the same issue here. Opening up a javascript file will cause codehelper to jump to 150% to 300% CPU usage. Tried remove the cache folders and resetting VS Code but it's not working.

The mitigation from the DefinitelyTyped PR has been merged - please do another cache clear and see how things are now. Note that after the cache clears, you will see a one-time perf hit during first launch - but after the types are downloading, interactive editing should be snappy again. Sorry again for the regression here.

Also you may need pin typescript to 3.3.4000.

Performance is still significantly worse than with 1.32.3. The styled-components update and cache clear reduce Code Helper's CPU usage, but do not fix it.

In our project, it takes several seconds for 1.33 to resolve a change from foo: string to foo: strin and back, with 100% CPU use from Code Helper. This would be nearly instantaneous with 1.32.

@metrip can you share a project that displays this behavior? We're particularly interested in your config file (if any)

Getting same problems as @metrip here, intellisense/typechecking are really slow :(

my config file:

{
"compilerOptions": {
"outDir": "./lib",
"module": "commonjs",
"target": "es6",
"lib": ["es2018", "dom"],
"sourceMap": true,
"jsx": "react",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"baseUrl": "./src"
},
"include": ["src/*/"],
"exclude": ["node_modules", "build", "scripts"]
}

The latest VS Code insiders build includes a new TypeScript version (3.4.3-insiders) that invalidates your automatic typings cache automatically. We will also be publishing this new TS version with our VS Code 1.33 recovery build (see #72005)

  • For JavaScript users: clearing the typings cache should ensure that you are using the patched version of the styled components typings.
  • For TypeScript users: if you have installed @types/styled-components, please make sure you have the most recent version of @types/styled-components installed in your workspace.

TypeScript 3.4.3 does not fix the root cause of this issue, which is tracked by https://github.com/Microsoft/TypeScript/issues/30819. If you still see performance problems related to tsserver after following the above instructions, please open a new issue and share information about your general project structure so that we can investigate further.

This bug is crippling my computer, in a simple gatsbyjs project using styled-components. Deleting /Users/(username)/Library/Caches/typescript and restarting VSCode does not resolve the issue for me. Interestingly, this is also happening on VSCode Insider.

The same bug has happened to me. I'm using styled-components with next.js framework.

I am using type checking for javascript files and the electron_node tsserver.js process is using more than 100% cpu.

@thakursaurabh1998 back to [email protected] or use typescript@next, then test again.

change the Terminal render type to dom @all solve the problem

change the Terminal render type to dom @ALL solve the problem

@xiaodoubaoldl could you explain how i can do that? thanks

setting=>search "terminal renderer type" =>change auto to dom @andrewcodes404

If you still see performance problems related to tsserver after following the above instructions, please open a new issue and share information about your general project structure so that we can investigate further.

It's still the same problem wether I use the new insiders or not
https://github.com/andrewcodes404/styledcomp-vscode-error/

Hey guys, I have successfully got rid of this problem just by following few steps mentioned here before.

  1. I have updated @types/node package to latest, currently have 11.13.2
  2. I have reinstalled typescript package to specific version 3.3.4000 which was recommended here
  3. In your VSCode use workspace version of typescript
  4. Kill VSCode
  5. Delete /home/(your username)/.cache/typescript/
  6. Run VSCode and all good

Hope this will work for you guys as well.

I had this issue for a couple days. Upgrading @types/styled-components from 4.1.12 to 4.1.14 and deleting /Users/<username>/Library/Caches/typescript fixed it for me. Thanks!

I had the same issue after upgrading to version 1.33, but after letting the program run for a little while, the CPU usage is now back to normal.

Looks like deleting the folder having issues and recloning them from git fixed the issue for me.

I'm closing this issue as the original problem @dziugasmeskauskas reported and that many others were also seeing was related to the styled components typings and clearing the caches (or updating the typings if you installed them locally) fixes things. See my comment for details.

Again, if you have followed all the instructions and still see performance issues related to tsserver, please open a new issue on github and we can investigate

2. 3.3.4000

hi @ondrejhudek, one week and still not working for me can I ask about your solution

_I have updated @types/node package to latest, currently have 11.13.2_
Is that globally or in your project? how did you do this?

_I have reinstalled typescript package to specific version 3.3.4000 which was recommended here_
is this global or local I do this $ npm install [email protected] but $ tsc -v still comes back with Version 3.4.3

_In your VSCode use workspace version of typescript_
Can you explain this further?

Thanks

If i create a new react next.js app with styled components it works fine, but in this project https://github.com/andrewcodes404/styledcomp-vscode-error2 everything grinds to a halt. Even when editing the react modules(not styled components) the CPU hits the roof with TSServer, I've followed the instructions, I have moved the project files and fresh install the npm modules but it still persists?

@mjbvz when you say _For JavaScript users: clearing the typings cache_
do you mean this cache /Users/(username)/Library/Caches/typescript . ?

@andrewcodes404 Are you using VS Code 1.33.1? It should clear cache automatically.

If you are still seeing problems, please open a new issue so we can continue investigating

I'm using Mac and VS Code 1.33.1, terminal.integrated.rendererType: "dom" already set on my setting from previous versions and it had high CPU usage when idle. Removing those setting solved the high CPU usage.

Well I guess the only way for me was to disable "TypeScript and JavaScript Language Features" :-D
I don't know what happened but I never had this pb before on my linux since the last update made today. But on my mac I have this trouble since a month now. And I did not add any extensions

Same for me on a new MBP 15" 2018. It was the same on my old MBP 15" 2015 (that I changed because of this bug by the way, I was thinking that my MBP was going mad in a middle of a sprint, so didn't have the time to check everything... So technically Microsoft owe me 3000€).

Still not resolve today, "TypeScript and JavaScript" build-in extension make my processus goes + 300%...

Up to this point, I hadn't had any luck resolving the issue for my workspace (gatsby + styled-components) using any of the methods suggested, including deleting /home/(your username)/.cache/typescript/

However, the problem went away after I checked _and_ unchecked Javascript > Implicit Project Config: Check JS in workspace settings after fiddling around. ¯\_(ツ)_/¯

Up to this point, I hadn't had any luck resolving the issue for my workspace (gatsby + styled-components) using any of the methods suggested, including deleting /home/(your username)/.cache/typescript/

However, the problem went away after I checked _and_ unchecked Javascript > Implicit Project Config: Check JS in workspace settings after fiddling around. ¯_(ツ)_/¯

~Seems to work for me too. Before the manipulation, got the processor at + 100% just by putting my cursor on a styled component. After the check/uncheck, no code helper pass above 70%, and go down very quickly.~

My bad, still having the processor going crazy...

@rdhox Nothing helped me as well. The only solution is to disable the build in extension TypeScript and JavaScript Language Features. You can find it by searching for in the extension menu @builtin TypeScript and JavaScript Language Features

屏幕快照 2019-05-20 下午11 57 20
@rdhox As mentioned by meritozh, this works for me. Hope this will work for you.

If you are seeing performance issue, try using latest VS Code insiders build.

Then if you are still seeing issues when using VS Code insiders (with TypeScript 3.5+), please open a new issue

Was this page helpful?
0 / 5 - 0 ratings