The following program:
import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
import fs2.Stream
object Main extends IOApp {
override def run(args: List[String]): IO[ExitCode] = {
val stream =
Stream
.iterate(0)(_ + 1)
.covary[IO]
.mapAsync(25) { n =>
if (n > 100) IO.raiseError(new RuntimeException)
else IO(println(n))
}
stream.compile.drain.as(ExitCode.Success)
}
}
when run somtimes hangs (never completes) indefinitely. It might take several runs/attempts for the hang to occur, but I'm always able to eventually trigger it locally.