Monix: Version 2.0.3 Released for Bug Fixing

This release is binary compatible with 2.0.x, being a bug fix release release for Issue #230: Deadlocks when blocking threads due to LocalBatchingExecutor (affects Task usage).

Basically the implementation of LocalBatchingExecutor assumed that the given LocalRunnable instances will not block the current thread. However there are clearly cases in which users and up blocking during a LocalRunnable. For example:

val source1 = Task(100)
val source2 = Task(200).onErrorHandleWith { case e: Exception => Task.raiseError(e) }

val derived = source1.map { x =>
  val r = Await.result(source2.runAsync, 10.seconds)
  r + x
}

val result = Await.result(derived.runAsync, 10.seconds)

This is clearly not idiomatic usage because blocking threads is evil, however it does happen in code and it has to work. As can be seen in the committed fix the JVM-specific implementation for the LocalBatchingExecutor now uses Scala’s BlockContext to workaround this limitation of our local trampoline.

Enjoy!