Use Visual Studio Code SSH without crashing your server
Have you used the Remote SSH extension in Visual Studio Code? You may not have realized, but with default settings it eats up a RIDICULOUS amount of cpu on the host.
On small or shared core servers, this can easily exceed 100% cpu capacity, shut down critical processes, and make the server useless real quick.
The solution is to disable the automatically enabled, totally hidden, idiotic TS/JS Language Service extension which installs and runs massive node processes on your server. Instructions at the bottom.
I’m a sublime text person. If not for one small shortcoming, I would still be using it 100% of the time — I’m in love with the speed, low resource usage, and pretty colors 😍
The one thing sublime text definitely lacks, though, is a good sftp client. Because of API limitations (and because sublime is a closed-source project maintained by ONE GUY!?) extensions like SFTP for Sublime can’t give a local-like dev experience, so you have to use weird workarounds like navigating entirely using the search bar.
This was annoying enough to make me willing to try something I said I’d never ever ever try again, since I bought my first Macbook in 2011……
I decided to try a Microsoft product 😭
Enter Visual Studio Code. Lately, I’ve noticed more and more of my friends gradually shifting over, and laughing at all the modifications they make to trick VS Code into looking like sublime text does out of the box.
I won’t rant too much more here, but in my opinion, the worst thing about Microsoft stuff is that their products which are supposed to ‘just work,’ never just fucking work, and you’ve always gotta do lots of tinkering to get something usable.
VS Code is apparently no different. The first time I booted it up and connected to my Google Cloud Compute micro instance, I got about half a second to appreciate the ‘tight remote experience,’ before VS Code disconnected. I thought ah, a reincarnation of the infamous Microsoft blue screen of death!
But then I tried to ssh in to my server via the terminal, and then I tried to browse to my site, and then I realized the ugly truth — VS Code crashed my server completely!!
Google’s Cloud monitoring showed a 100%+ cpu spike at the same time VS Code connected.
I did a little research about how SFTP works, but unfortunately there’s little to no documentation about what VS Code is doing behind the scenes.
I eventually figured out that the Remote extension in VS Code works by installing a bunch of stuff on your server. I restarted the server and ran top, to see exactly what. I found these crazy node processes:
100% cpu for AUTOCOMPLETE! And they never tell you it’s there, and there’s no instructions for disabling it.
So long story short, if you’re tired of VS Code eating up all your cpu, here’s what you need to do.
- Hit the extensions button in VS Code (which looks like building blocks on the left toolbar)
- Search for ‘@builtin TypeScript’.
Voila! You’ve officially tinkered your Microsoftware in to being actually usable!
And honestly, though I’ve been pretty hard on it, once you get the kinks worked out, VS Code can be pretty nice :) Best of all, it’s mostly open source, so when you encounter more questionable design decisions, you can probably go in and fix them yourself.