Typescript: TSServer using 100%+ CPU breaking Intellisense, import suggestions etc

Created on 6 May 2020  ·  7Comments  ·  Source: microsoft/TypeScript

Issue Type: Performance Issue

As soon as I open a JS file and begin editing, TSServer begins using a huge amount of CPU and intellisense etc ceases to function correctly. This happens with all extensions disabled.

My jsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "jsx": "react"
  },
  "include": ["./src/**/*.js"],
  "exclude": [
    "node_modules",
    "dist",
    "coverage",
    "demo",
    "static",
    "public",
    ".cache"
  ]
}

I'm not using TypeScript, but if I create a .ts file in my project I can see the version is 3.8.3. I have tried installing the JavaScript and Typescript Nightly extension which gives me 4.0.0-dev.20200505 and if anything the performance is worse. Data below was captured with Nightly extension disabled.

I'm running a 2019 Macbook Pro with maxed out specs. At this point VSCode is effectively unusable.

Running ps aux PROCESS ID for the tsserver process:

USER         PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
pedrbrowne  6264 158.0  2.6  7101256 866400   ??  R     9:37am   0:48.90 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --max-old-space-size=3072 /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/_0/7sk3xl9n18ldl4zswn5_xm6c0000gq/T/vscode-typescript503/e40452cb257dfd4b6c9b/tscancellation-d3202bc4e76652be5db2.tmp* --logVerbosity verbose --logFile /Users/pedrbrowne/Library/Application Support/Code/logs/20200506T093701/exthost1/vscode.typescript-language-features/tsserver-log-s7OhZ6/tsserver.log --globalPlugins typescript-vscode-sh-plugin --pluginProbeLocations /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation

This is a follow-on from https://github.com/microsoft/vscode/issues/96255 and possibly related to https://github.com/microsoft/TypeScript/issues/38329

Possibly related: My jsconfig.json file is coloured red in the sidebar. the opening bracket is underlined as an error, and when I roll over the bracket I get this popup (note that axios-mock-adapter is a nested-dependency:

Screenshot 2020-05-06 at 12 25 26

VS Code version: Code 1.44.2 (ff915844119ce9485abfe8aa9076ec76b5300ddd, 2020-04-16T17:07:18.473Z)
OS version: Darwin x64 18.7.0


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz (12 x 2900)|
|GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled|
|Load (avg)|10, 23, 16|
|Memory (System)|32.00GB (1.36GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|


Process Info

CPU %   Mem MB     PID  Process
   12      131    4804  code main
    4       98    4805     gpu-process
    0       33    4807     utility
    9      295    4808     window (nodeFields.js — sleepstation-public)
    0       98    4816       extensionHost
    0       66    6248         electron_node tsserver.js 
  103      918    6264         electron_node tsserver.js 
    0       98    6549           electron_node typingsInstaller.js typesMap.js 
    0       33   10475         /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/jsonServerMain --node-ipc --clientProcessId=4816
    0        0    4817       /bin/bash -l
    0       33    5411       watcherService
    0       33   10759       searchService
    0      262    4809     window (.eslintignore — frontend)
    0       66    4818       extensionHost
    0        0    4823       /bin/bash -l
    0       33    4959       watcherService
    0      295    4810     window (jest.config.js — sleepstation-admin)
    0       66    4828       extensionHost
    0       66    5604         electron_node tsserver.js 
    0      426    5607         electron_node tsserver.js 
    0       66    5713           electron_node typingsInstaller.js typesMap.js 
    0       33   10440         /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/jsonServerMain --node-ipc --clientProcessId=4828
    0        0    4829       /bin/bash -l
    0       33    5343       watcherService
   21      131    5526     shared-process
    0        0   10788       /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=
   32       66   10786     window (Issue Reporter)



Workspace Info

|  Window (jest.config.js — redacted-admin)
|  Window (.eslintignore — frontend)
|  Window (nodeFields.js — redacted-public)
|    Folder (redacted-public): 4244 files
|      File types: json(744) js(666) jpg(479) png(443) svg(387) md(246)
|                  pdf(32) DS_Store(29) mp4(24) yml(6)
|      Conf files: package.json(3) jsconfig.json(1) settings.json(1)
|    Folder (frontend): 2525 files
|      File types: js(1538) svg(105) json(46) DS_Store(32) md(27) sh(5) hbs(5)
|                  crt(4) log(3) key(2)
|      Conf files: package.json(38) jsconfig.json(1) launch.json(1)
|                  settings.json(1) webpack.config.js(1)
|      Launch Configs: chrome
|    Folder (redacted-admin): 419 files
|      File types: js(180) png(55) json(43) md(8) hbs(5) crt(4) DS_Store(2)
|                  yml(2) key(2) ico(2)
|      Conf files: jsconfig.json(1) package.json(1) webpack.config.js(1)
|                  launch.json(1) settings.json(1)
|      Launch Configs: chrome;


Extensions: none

Needs Investigation Rescheduled

Most helpful comment

@mjbvz Happy to share any logs or profiling that might help, but unfortunately I cannot share this project as it is closed-source, however the problem definitely lies with: `'TypeScript: Disable Automatic Type Acquisition'. I've had it checked/disabled for days with only a couple of instances of VSCode locking up (compared to it happening near-permanently before). I just tried checking it again, and pretty much instantly the process jumped to 100%+ cpu and VScode locked up. Rechecking it reversed the issue and VSCode is usable again.

All 7 comments

Update: Checking 'TypeScript: Disable Automatic Type Acquisition' appears to have helped.

@Undistraction Are you able to share a project that triggers this behavior? Does it seem to be triggered when you open one file in particular?

@mjbvz This project triggers this for me elastic-charts. Any typescript file. If you just start clicking into definitions, you should run into this issue. Let me know if you are not able to repro and I can get more accurate steps to repro.

Note: some of my teammates on the same project have no issues.

@mjbvz Happy to share any logs or profiling that might help, but unfortunately I cannot share this project as it is closed-source, however the problem definitely lies with: `'TypeScript: Disable Automatic Type Acquisition'. I've had it checked/disabled for days with only a couple of instances of VSCode locking up (compared to it happening near-permanently before). I just tried checking it again, and pretty much instantly the process jumped to 100%+ cpu and VScode locked up. Rechecking it reversed the issue and VSCode is usable again.

@mjbvz were you able to reproduce the issue? This is a daily issue that comes and goes, forcing me to use IntelliJ.

@mjbvz This problem has returned with version 1.46.1, making VSCode almost unusable for me.

I am experiencing the same problem in VSCode 1.46.1 (MacOS 10.15.5).
I can see from process explorer that ts-server uses 100% of the CPU.
So far the only workaround that I found is to manually kill the process from Activity Monitor.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wmaurer picture wmaurer  ·  3Comments

Roam-Cooper picture Roam-Cooper  ·  3Comments

fwanicka picture fwanicka  ·  3Comments

uber5001 picture uber5001  ·  3Comments

siddjain picture siddjain  ·  3Comments