Ubuntu – VS Code causes 17.10, 18.04 randomly and completely freeze

17.1018.04visual-studio-code

Please read: See the last bit. I don't believe this is an issue related to Ubuntu, but rather VS Code.

Recently, under 17.10 and 18.04 (I just upgraded today), Ubuntu will randomly and completely freeze. I cannot move the cursor or use the keyboard. Naturally, I have tried switching to a TTY session with no success. Every time, I must resort to SysRq + REISUB, which is (obviously) not preferred.

I have attempted to switch graphics drivers, on the theory that it may be that. I was originally using the open source nVidia driver, and switched to the proprietary to no avail. I'm currently using the open source driver.

All that I typically have open is Firefox (not a ton of tabs loaded) and VS Code, with at most a couple files and a terminal open.

Any ideas?

Update: The system logs show no indication of anything at all happening, let alone something wrong. I don't know if this is related, but sometimes (and especially after booting) programs take a significant amount of time (> 5-10 seconds), even command line programs.

Yet another update! — Even with all GNOME extensions disabled, it still crashed. I tried XFCE, which still crashed.

Summary: Ubuntu completely freezes at seemingly random times, leaving no trace in logs, and is not related to any specific desktop environment or GNOME extensions.

(likely final) update: I'm convinced this is an issue with VS Code. I have been running GNOME for days, with other Electron apps open (Slack, Pulse, etc.), and have not had a single freeze. I have DM'd VS Code on Twitter, and will likely file a bug report as they haven't responded yet.

Apparently, even though I'm ignoring certain files using the files.exclude setting (notably the ./node_modules directory), VS Code still watches those files for changes.
To solve that, simply copy the list from files.exclude to files.watcherExclude. This will prevent VS Code from searching the many thousands of files that are in node_modules or other similar directories. That way, it will leave some RAM for Chrome to gobble up.