Skip to content

Commit c2c9fff

Browse files
committed
Recover from execution exceptions on parallel compile requests to Bloop
1 parent 6c9bdaa commit c2c9fff

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

modules/build/src/main/scala/scala/build/Bloop.scala

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import java.io.{File, IOException}
1212
import scala.annotation.tailrec
1313
import scala.build.EitherCps.{either, value}
1414
import scala.build.errors.{BuildException, ModuleFormatError}
15-
import scala.build.internal.CsLoggerUtil._
15+
import scala.build.internal.CsLoggerUtil.*
16+
import scala.concurrent.ExecutionException
1617
import scala.concurrent.duration.FiniteDuration
17-
import scala.jdk.CollectionConverters._
18+
import scala.jdk.CollectionConverters.*
1819

1920
object Bloop {
2021

@@ -37,8 +38,10 @@ object Bloop {
3738
): Either[Throwable, Boolean] =
3839
try {
3940
logger.debug("Listing BSP build targets")
40-
val results = buildServer.workspaceBuildTargets()
41-
.get(buildTargetsTimeout.length, buildTargetsTimeout.unit)
41+
val results = retry()(logger) {
42+
buildServer.workspaceBuildTargets()
43+
.get(buildTargetsTimeout.length, buildTargetsTimeout.unit)
44+
}
4245
val buildTargetOpt = results.getTargets.asScala.find(_.getDisplayName == projectName)
4346

4447
val buildTarget = buildTargetOpt.getOrElse {
@@ -61,6 +64,11 @@ object Bloop {
6164
case ex @ BrokenPipeInCauses(e) =>
6265
logger.debug(s"Caught $ex while exchanging with Bloop server, assuming Bloop server exited")
6366
Left(ex)
67+
case ex: ExecutionException =>
68+
logger.debug(
69+
s"Caught $ex while exchanging with Bloop server, you may consider restarting the build server"
70+
)
71+
Left(ex)
6472
}
6573

6674
def bloopClassPath(

0 commit comments

Comments
 (0)