typelevel / typelevel/cats-effect
TestControl + Dispatcher == deadlock
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.2k
- Forks
- 576
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 18
Description
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
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Scala reproduction using cats-effect-testkit 3.5.4, focusing on the interaction between TestControl.executeEmbed and Dispatcher.sequential or parallel unsafeRunSync. Confirm whether the program remains blocked and whether the timeout fails to fire; done means the reproduction completes without deadlocking and the timeout behavior is restored.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100