TypeScript: VSCode incredibly slow, 100% CPU usage, coming from electron_node tsserver.js CPU usage

  • VSCode Version: 1.48.0
  • OS Version: iOS Catalina 10.15.5

Steps Attempted to Resolve issue:

  1. Disable all extensions except typescript/javascript features
  2. Install JS and TS Nightly extension as recommended
  3. Downgrading to previous version of VSCode (1.32.0)
  4. Installing latest VSCode Insiders
  5. Increased max memory allowed by typescript server
  6. Check to make sure no extension takes more than 100ms to load

Additional Info

The project is 200k lines and smaller projects do not have the issue. Its primarily related to typescript because if I disable the built-in javascript/typescript features then the tsserver doesn’t spin up, so no problem.

  • The hovering types are almost always at “loading…” state.
  • Cmd Clicking into types to see what they are is also insanely slow and practically unusable
  • Autocomplete is incredibly slow, and often nonexistent, even for basic commands like ‘clo’ for console.logs
  • Red error lines from intellisense are 2-5min lagging behind my actual changes. its like vscode is hung up

If I open the project freshly, find an object, and change a variable to gibberish, then it will take several minutes for VSCode to complain to me with intellisense. Simply saving, and running the app in the browser with auto-reload is faster because chrome will show me compile errors

Below is the result of running ps aux | grep [number]:

jfarris          90151 100.8  1.6  7160436 550880   ??  R     9:30AM   9:16.20 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --max-old-space-size=8072 /Users/jfarris/Documents/amaro-ui/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --enableTelemetry --cancellationPipeName /var/folders/mg/97w2bx6d1fqdkyd9bmyh6sd00000gp/T/vscode-typescript502/31ba41063dba52b8428d/tscancellation-0b463b00b389646856b1.tmp* --globalPlugins typescript-vscode-sh-plugin --pluginProbeLocations /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation

jfarris          92342   0.0  0.0  4408572    816 s002  S+    9:40AM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox 90151

Below is the process explorer - notice the tsserver.js using more than 100%. This happens when turning on VSCode > it then slows down to normal number > then i start editing in VSCode and it jumps back up > it stays up for 2-3min AFTER I’ve stopped editing > then finally slows down. But sometimes it just stays at 100 even 5+ min after I’ve finished editing

Screen Shot 2020-08-14 at 9 39 47 AM

Below is the CPU usage from the activity monitor

Screen Shot 2020-08-14 at 9 39 23 AM

Does this issue occur when all extensions are disabled?: Yes/No

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 23
  • Comments: 25 (6 by maintainers)

Most upvoted comments

Yes! VS CODE is awful after the latest update.

This has been solved.

My tsconfig.json had includes which contained file paths that did not exist in the particular repo, causing an infinite loop of trying to open files in that directory that didn’t exist I suppose

There are a number of community packages that seem to commonly cause sluggishness and high CPU usage from TS. For me this is mobx-state-tree. In my project I have consistently very high CPU usage from TS and slow (5-10 second) autocomplete, go-to, and error highlighting. Other common culprits seem to be rxjs, MUI, ramda, xstate, and styled-components. Are those of you having problems using any of these dependencies?

Hi there. I can share a file on which issue reproduces stable for me: https://github.com/aleksei-berezkin/fluent-streams/blob/master/src/impl/stream.test.ts

Observed behavior: whenever I edit a file in VSCode, a process running tsserver.js starts a work consuming 100% of CPU, and it takes about 12–14 seconds on my machine to complete. (MacBook Pro with 16 GB RAM and i7). This reproduces on each edit.

I made a small research and found out that it’s likely type inference triggered by getSemanticDiagnostics. I can take additional profile or dump if you wish.

VS Code “about” output:

Version: 1.49.2 Commit: e5e9e69aed6e1984f7499b7af85b3d05f9a6883a Date: 2020-09-24T16:23:52.277Z (5 days ago)

Then please collect the TS Server log:

  1. In the VS Code settings, set "typescript.tsserver.log": "verbose",
  2. Restart VS Code and reproduce the problem
  3. In VS Code, run the TypeScript: Open TS Server log command
  4. This should open a large log file called tsserver.log

If you can share the log, we will take a look to see if anything stands out

⚠️Warning: The TypeScript log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on Github, just let me know and we can arrange something else. On our side, we only use these logs to investigate issues like this