Skip to content

TSServer High CPU usage #31248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kasik96 opened this issue Mar 21, 2019 · 29 comments
Closed

TSServer High CPU usage #31248

kasik96 opened this issue Mar 21, 2019 · 29 comments
Assignees
Labels
Domain: Performance Reports of unusually slow behavior Needs More Info The issue still hasn't been fully clarified

Comments

@kasik96
Copy link

kasik96 commented Mar 21, 2019

  • VSCode Version: 1.32.3
  • OS Version: Fedora 29

Steps to Reproduce:

  1. Install clean stable VSCode with neo extensions or setting
  2. Open large project with sub projects
  3. Check System Monitor -> HIGH CPU Usage, almost non usable OS

I tried to turn off some settings, but nothing help.
It caused by TSServer.js build-in "TypeScript and JavaScript Language Features" extension.

Solution: Disable "TypeScript and JavaScript Language Features" build-in extensions.

Screenshot from 2019-03-21 11-18-59
Screenshot from 2019-03-21 11-19-27
Screenshot from 2019-03-21 11-19-56

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

@mjbvz
Copy link
Contributor

mjbvz commented Mar 21, 2019

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

@kasik96
Copy link
Author

kasik96 commented Mar 21, 2019

@mjbvz Yes :/
Screenshot from 2019-03-21 19-20-16

@kasik96
Copy link
Author

kasik96 commented Mar 21, 2019

Also i have the same problem with Ubuntu (Unity, XFCE), Mate and Fedora.

@kasik96
Copy link
Author

kasik96 commented Mar 26, 2019

@mjbvz Any update on this bug? Also tested on Manjaro, i have same problem. It does not look it happens on Windows, it has little more CPU use, but not that much as in Linux.

@ZachGoldberg
Copy link

Same here. Ubuntu 18.04. Identical symptoms. Disabling JS & TS features built-in also fixes it.

@abhishek-rs
Copy link

Have the same issue on MacOS Mojave. Using this as a workaround -

  1. Disable the default javascript validation -
    "javascript.validate.enable": false
  2. Use the external ESLint extension - https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

@mjbvz
Copy link
Contributor

mjbvz commented Apr 18, 2019

@kasik96 Please try collecting the TS Server log:

  1. 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 folder with a tsserver.log file in it

If you can share the log, I can also take a look to see if anything stands out that could be causing this

⚠️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

@kasik96
Copy link
Author

kasik96 commented Apr 18, 2019

@mjbvz Yeah, no problem, here it is: https://gist.github.com/kasik96/0af966b0b28f7a118025e50f943429d8

@stefems
Copy link

stefems commented Apr 24, 2019

+1
I'm having the same cpu issue with eletron_node tsserver.js as shown in the vs code process explorer. Pls fix soon. My laptop has been melting my fingers. Suggestion by abhishek-rs has been working thus far.

@npesa92
Copy link

npesa92 commented May 1, 2019

+1 Having the same issue here. One line change will spike CPU and show electron_node tsserver.js as the problem

@SeedyROM
Copy link

SeedyROM commented May 3, 2019

+1 Can confirm on Ubuntu 16.04, problem seems to be stemming from tsserver. I have nearly identical logs to kasik96. Use an older version of VSCode in the mean time instead of trying to hack this into working!

@mjbvz mjbvz transferred this issue from microsoft/vscode May 4, 2019
@mjbvz
Copy link
Contributor

mjbvz commented May 4, 2019

Moving this upstream as I don't see anything that stands out in those logs.

Can you please try upgrading your workspace to use typescript@next by following these instructions just to make sure this hasn't already been fixed

@mjbvz mjbvz removed their assignment May 4, 2019
@kasik96
Copy link
Author

kasik96 commented May 5, 2019

@mjbvz Same problem, did not help.

@Mozar10
Copy link

Mozar10 commented May 6, 2019

I have tried pretty much every solution listed here and in other gh issues. Have tried removing extensions, upgrading TS, etc.. and I'd really hate to switch to atom. Is there any fix for this? Pretty sure it's limited to linux os

@brokenalarms
Copy link

no @Mozar10, this is happening for me on MacOS as well.

@sheetalkamat
Copy link
Member

@kasik96 From your shared log it seems like file watcher being invoked too many times and is suppose to be a file not found.. Enabling --traceResolution might give you why this file is being requested. It seems like that location is directory in the package and not file.

Info 179  [20:40:57.774] FileWatcher:: Triggered with /home/jsdev/Work/hidden-clients-js/node_modules/socks/typings 0:: WatchInfo: /home/jsdev/Work/hidden-clients-js/node_modules/socks/typings 500 Project: /dev/null/inferredProject1* WatchType: Missing file

Info 180  [20:40:57.774] FileWatcher:: Close:: WatchInfo: /home/jsdev/Work/hidden-clients-js/node_modules/socks/typings 500 Project: /dev/null/inferredProject1* WatchType: Missing file

@weswigham weswigham added Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior labels May 8, 2019
@wclr
Copy link

wclr commented May 10, 2019

It happens very often (several times during a day) to me with my medium size projects, tsserver (eletron_node tsserver.js) starts to eat 30%-70% CPU on any currently active file in the editor (I see it in vscode's Process Explorer).

When I restart vscode it's working fine on the same files, sometime later it begins again. It really hard to believe that there is something "wrong" with the app's TS code.

Using Windows 10, latest stable VSCode, and TS stable 3.4.5

@SeedyROM
Copy link

Just downgrade your version, the last update doesn't have anything that's actually's worth upgrading for if this bug is affecting you. Wait till they figure it out guys!

@Mozar10 You don't need to go to Atom, just download the last release here!

@Mozar10
Copy link

Mozar10 commented May 12, 2019

@SeedyROM Thanks for the tip. That didn't cross my mind and so far so good 👍

@wclr
Copy link

wclr commented Jun 10, 2019

I have downgraded to vscode 1.32 but the problem is the same, it periodically became hight then some minutes later goes down back.

@RyanCavanaugh RyanCavanaugh added Needs Investigation This issue needs a team member to investigate its status. and removed Bug A bug in TypeScript labels Jun 12, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.6.0 milestone Jun 12, 2019
@DanielRosenwasser DanielRosenwasser removed this from the TypeScript 3.6.0 milestone Jul 19, 2019
@graupe
Copy link

graupe commented Sep 2, 2019

I had the same issue when opening files in larger typescript projects. I would say it's a bug at some level, but I could make it go away by using sudo sysctl fs.inotify.max_user_watches=524288 on my Linux system. Hope this helps someone.

@MatthewCushing
Copy link

MatthewCushing commented Oct 10, 2019

This just started happening to me out of the blue in DeepinOS but I just switched a couple days ago so I'm not sure if I hadn't been paying attention and it was doing it all along. Extremely frustrating as my laptops fans start going full speed and typescript's intellisense takes forever to load instead of the instantaneous feedback I'm used to.

Going into htop shows usally all CPUs having an increase in usage with one of them at 99%.
Looking at my processes, there are literally TONS of the same tsserver popping up like my processes are being flooded with multiples of the same process.

I first noticed this yesterday when I tried to run Gatsby and it errored out saying I had too many file watchers. I have also tried every solution I could find and even upgraded from I believe 1.31 to 1.39 and that didn't work so finally decided to post here. I haven't enabled verbose logging and looked at the logs yet so I'll do that now and report back.

Makes me so sad :(. I love VSCode too much for this to ruin my experience but there's no way I can handle my laptop sounding like a turbine and my intellisense taking 5-10 seconds to load while I type.

As an aside, this only starts happening when I start typing.

EDIT: And I'm running on a Lenovo Yoga 920 if that matters

@MatthewCushing
Copy link

MatthewCushing commented Oct 10, 2019

Alright, I attached my tsserver log. I REALLY hope this helps. I literally turned on verbose logging, exited VSCode, re-opened VSCode, typed a couple characters in a .tsx file and everything spiked. So this is like a log of a minute of time frame and I hope it helps point down the issue.
tsserver_log.txt

EDIT: Apologies, that one had some extensions running. The following log has no extensions enabled.
tsserver_log.txt

It seems to be adding file watchers to directories like node_modules?
I have:

  1. a gitignore that excludes that
  2. workspace settings for "files.watcherExclude" that specifically excludes node_modules and others

It seems like on Linux it is ignoring these settings and they are not taking effect

EDIT: I tried opening only my src/ directory so that node_modules or .cache or any of that was not even apart of it. Same issue and looking through the log, it's still checking node_modules? Forgive my ignorance on this but I assumed it would have ignored it. Damn.

EDIT: Deleting node modules folder resolves the issue. Re-installing node modules causes issue to reappear

LAST EDIT: I'm pretty sure I found the issue. It's the npm module react-spring. I had just added it in yesterday and removing the module gives me a lot more performance and my intellisense works flawlessly. However, when I add it is when I get the 5-10 second load times on intellisense and my CPU spikes to 100%.

However, tsserver is still not avoiding file watching node_modules and my CPU use is still really high to the point that my laptop still decides to act like a wind turbine. So this issue still exists, I only noticed it after having intellisense issues. Hopefully the logs I have posted and my own debugging effort here has helped a bit.

Swear my last edit: Seems like people at react-spring know about this issue and it all comes back to this bug in typescript. Thus, react-spring was essentially just the last straw for vscode to where it exploded and almost melted my cpus.

So you know, this is their issue opened: pmndrs/react-spring#613

And this is the typescript bug they are referencing that they think is causing this whole mess: #29949

@RyanCavanaugh RyanCavanaugh added Needs Investigation This issue needs a team member to investigate its status. and removed Needs More Info The issue still hasn't been fully clarified labels Oct 29, 2019
@arielsalminen
Copy link

Have been facing this exact issue as well on the latest macOS for the past few weeks and haven’t been able to solve it.

@sheetalkamat
Copy link
Member

sheetalkamat commented Jan 30, 2020

@cushmatt can you please try typescript@next to see if the issue still repros.. We made some changes to directory watching for Linux and it might have fixed the issue with the files being watched..
If the issue still repros, please share new tsserver log with the latest build when the issue repros to be able to investigate this further

@sheetalkamat sheetalkamat added Needs More Info The issue still hasn't been fully clarified and removed Needs Investigation This issue needs a team member to investigate its status. labels Jan 30, 2020
@sheetalkamat sheetalkamat removed this from the TypeScript 3.8.1 milestone Jan 31, 2020
@MaestroJurko
Copy link

I am still experiencing this issue with VSCode Insider and typescript@next.

@mjbvz
Copy link
Contributor

mjbvz commented Apr 23, 2021

@puppeteer701 Please open a new issue with information about your project

Closing this since we cannot investigate this without more info from the original poster

@mjbvz mjbvz closed this as completed Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Performance Reports of unusually slow behavior Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests