bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://ij.bazel.build/
Apache License 2.0
761 stars 303 forks source link

Syncing doesn't finish when there are build errors #6603

Open jmmv opened 1 month ago

jmmv commented 1 month ago

Description of the bug:

We have a situation where the IntelliJ sync process "never finishes" when there are build errors in the Java code of our project. Well, the sync maybe finishes, but it just takes way too long due to excessive resource utilization. The way this manifests is in a stuck JetBrains Gateway or in a super-high IntelliJ memory consumption.

We have tracked this down to the BEP generated by Bazel being huge when there are build errors. In a normal sync for our project, the BEP that Bazel writes is a few hundred MBs big, but when the build fails, the BEP is several GBs in size. IntelliJ then chokes trying to process this output.

I compared the JSON BEP written with a good and a bad build and found that the bad build contains lots more progress and namedSet entries. For comparison, here is what a good build shows:

...
      3     "structuredCommandLine": {
  47424     "targetCompleted": {
  47424     "targetConfigured": {
 143851     "namedSet": {
 191278     "progress": {

and here is what a bad build shows:

...
      3     "structuredCommandLine": {
  47424     "targetCompleted": {
  47424     "targetConfigured": {
1255596     "namedSet": {
1303024     "progress": {

I wonder if #1167 is related to what we are seeing.

The theory in my head for the above is this: if we have two chains of actions A->B->C and A->B->D, and B fails to build, then the aspect will still try to generate data for C and D, but now the build failures of B are “accounted” towards the outputs of C and D. This results in extra progress messages and extra “outputs” via namedSet. Propagate this throughout our large tree and we end up with this issue blowing up the size of the BEP.

The problem only shows up when --keep_going and the plugin aspect are combined. It doesn't show up otherwise.

Which category does this issue belong to?

Intellij

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Introduce a Java compilation error in a project, probably in one of the base libraries of the build graph.

Which Intellij IDE are you using? Please provide the specific version.

JetBrains Gateway 2023.3.4

What programming languages and tools are you using? Please provide specific versions.

Java

What Bazel plugin version are you using?

2024.04.23-stable

Have you found anything relevant by searching the web?

See the description.

Any other information, logs, or outputs that you want to share?

No response

tpasternak commented 1 month ago

So unfortunately I can't reproduce it. Could you please try to catch a stacktrace next time it happens?

tpasternak commented 1 month ago

btw we recently found this https://github.com/bazelbuild/intellij/issues/6577