cats-effect
cats-effect copied to clipboard
TestControl + Dispatcher == deadlock
trafficstars
Using CE 3.5.4, invoking a Dispatcher#unsafeRunSync in a program run with TestControl appears to deadlock
//> using dep "org.typelevel::cats-effect-testkit:3.5.4"
import cats.effect.IOApp
import cats.effect.IO
import cats.effect.std.Dispatcher
import scala.concurrent.duration._
import cats.effect.testkit.TestControl
object Main extends IOApp.Simple {
// exact same thing happens using parallel
val program = Dispatcher.sequential[IO].use { dispatcher =>
IO(dispatcher.unsafeRunSync(IO(1)))
}
def run: IO[Unit] =
TestControl
.executeEmbed(program)
.flatMap(IO.println)
.timeout(2.seconds) // timeout doesn't kick-in
}