VSCode extension 100% CPU usage

  • Operating system: Win10
  • SonarQube for VS Code plugin version: 4.14.1
  • Programming language you’re coding in: java
  • Is connected mode used: none

When I enable or install SonarQube extension on running VSCode (with Redhat’s Java), then everything is working just fine.
But if I restart VSCode - it keeps utilizing 100% CPU with permanently throwing exceptions in SonarQube for IDE output:

[Error - 17:08:23.865] Unable to get Java config.
java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.CompletableFuture.timedGet(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.get(Unknown Source)
	at org.sonarsource.sonarlint.ls.java.JavaConfigCache.getOrFetch(JavaConfigCache.java:64)
	at org.sonarsource.sonarlint.ls.folders.ModuleEventsProcessor.lambda$isTestFile$3(ModuleEventsProcessor.java:130)
	at org.sonarsource.sonarlint.ls.file.FileTypeClassifier.isTest(FileTypeClassifier.java:42)
	at org.sonarsource.sonarlint.ls.folders.ModuleEventsProcessor.isTestFile(ModuleEventsProcessor.java:130)
	at org.sonarsource.sonarlint.ls.folders.ModuleEventsProcessor.lambda$getClientFileDto$1(ModuleEventsProcessor.java:118)
	at java.base/java.util.Optional.ifPresentOrElse(Unknown Source)
	at org.sonarsource.sonarlint.ls.folders.ModuleEventsProcessor.getClientFileDto(ModuleEventsProcessor.java:113)
	at org.sonarsource.sonarlint.ls.folders.ModuleEventsProcessor.notifyBackendWithFileLanguageAndContent(ModuleEventsProcessor.java:94)
	at org.sonarsource.sonarlint.ls.SonarLintLanguageServer.lambda$didOpen$5(SonarLintLanguageServer.java:460)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

This process is endless - when left running for many hours, found crashed VSCode.

To make it working again, have to disable SonarQube extension, restart extensions or whole VSCode, wait till Java Projects are properly loaded, and then enable SonarQube again - only then it works as expected. Till next VSCode restart - on new start it falls into 100% CPU loop again. As a workaround, have to disable SonarQube extension before each shutdown.

What did I try:

  • uninstall SonarQube extension
  • manual deletion of %USERPROFILE%\.vscode\extensions\sonarsource.sonarlint-vscode-4.14.1-win32-x64\ folder
  • rollback to 4.13.0-4.14.0
    Unfortunately nothing helps.

Upd. Clean VSCode install with erasing %APPDATA%\Code and %USERPROFILE%\.vscode didn’t help.

Hello, welcome to the community! And thanks for reporting this behavior.

If I understand correctly, what happens here is that the RedHat Java extension is taking a lot of time to load the project structure, which results in timeouts for the call that SonarQube for IDE does to get the Java settings.

I created a ticket to investigate what we could improve in such a situation.

Out of curiosity, what kind of project is loaded in VSCode when this happens? Is it Gradle/Maven/something else? How many (sub)modules?

I have many projects/folders with this behaviour. Typically each folder contains one or two java-modules with gradle and webflux spring boot, and couple more modules (frontend, docker). And it’s true that java module takes some time (up to 2-4 minutes) to get initialized.

I think it makes sense somehow to rework startup of the modue, though not sure if vscode api provides any events like “redhat.java module initialized”.

Or, for example, make timeout configurable via profile’s settings.json: SonarQube