Skip to content

Commit f96162e

Browse files
authored
Retry coursier artifact loading when "checksum not found" (#2058)
We reuse the same retry logic as we do for retrying concurrent download issues. Fix #1910 Pull request: #2058
1 parent 0f87161 commit f96162e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

main/src/mill/modules/Jvm.scala

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import scala.annotation.tailrec
3636

3737
object Jvm {
3838

39-
private val ConcurrentRetryCount = 5
40-
private val ConcurrentRetryWait = 100
39+
private val CoursierRetryCount = 5
40+
private val CoursierRetryWait = 100
4141

4242
/**
4343
* Runs a JVM subprocess with the given configuration and returns a
@@ -583,7 +583,7 @@ object Jvm {
583583

584584
@tailrec def load(
585585
artifacts: Seq[coursier.util.Artifact],
586-
retry: Int = ConcurrentRetryCount
586+
retry: Int = CoursierRetryCount
587587
): (Seq[ArtifactError], Seq[File]) = {
588588
import scala.concurrent.ExecutionContext.Implicits.global
589589
val loadedArtifacts = Gather[Task].gather(
@@ -597,12 +597,19 @@ object Jvm {
597597
}
598598
val successes = loadedArtifacts.collect { case (_, Right(x)) => x }
599599

600-
if (retry > 0 && errors.exists(_.describe.contains("concurrent download"))) {
600+
if (retry > 0 && errors.exists(e => e.describe.contains("concurrent download"))) {
601601
ctx.foreach(_.log.debug(
602602
s"Detected a concurrent download issue in coursier. Attempting a retry (${retry} left)"
603603
))
604-
Thread.sleep(ConcurrentRetryWait)
604+
Thread.sleep(CoursierRetryWait)
605605
load(artifacts, retry - 1)
606+
} else if (retry > 0 && errors.exists(e => e.describe.contains("checksum not found"))) {
607+
ctx.foreach(_.log.debug(
608+
s"Detected a checksum download issue in coursier. Attempting a retry (${retry} left)"
609+
))
610+
Thread.sleep(CoursierRetryWait)
611+
load(artifacts, retry - 1)
612+
606613
} else (errors, successes)
607614
}
608615

@@ -683,7 +690,7 @@ object Jvm {
683690
import scala.concurrent.ExecutionContext.Implicits.global
684691

685692
// Workaround for https://github.com/com-lihaoyi/mill/issues/1028
686-
@tailrec def retriedResolution(count: Int = ConcurrentRetryCount): Resolution = {
693+
@tailrec def retriedResolution(count: Int = CoursierRetryCount): Resolution = {
687694
val resolution = start.process.run(fetch).unsafeRun()
688695
if (
689696
count > 0 &&
@@ -693,7 +700,7 @@ object Jvm {
693700
ctx.foreach(_.log.debug(
694701
s"Detected a concurrent download issue in coursier. Attempting a retry (${count} left)"
695702
))
696-
Thread.sleep(ConcurrentRetryWait)
703+
Thread.sleep(CoursierRetryWait)
697704
retriedResolution(count - 1)
698705
} else resolution
699706
}

0 commit comments

Comments
 (0)