Monix v3.4.0 Release Notes

Release Date: 2021-05-14 // about 3 years ago
  • πŸš€ The release is binary and source compatible with 3.x series, and was cross-built for the following Scala and ScalaJS versions:

    • Scala 2.12, 2.13 and 3.0
    • Scala.js 1.5.1

    WARN: we're dropping compatibility with Scala 2.11 and ScalaJS 0.6.x. If you still need those you'll have to stay on version 3.3.0.

    πŸš€ Changes in this release:

    • ⬇️ Dropped support for Scala 2.11 and Scala.js 0.6.x
    • ⚑️ Dependency updates:
      • Cats 2.6.1
      • Cats-Effect 2.5.1
      • JCTools 3.3.0
    • βž• Adds support for Scala 3 (#1326, #1327, #1328, #1329, #1344, #1323)
    • βž• Adds Observable.whileBusyAggregateEvents (#1320)
    • πŸ›  Fix tracing in Coeval and Task via a more accurate filter (#1353)
    • βž• Adds Observable.throttleLatest (#1396)
    • Implement pagination for Observable (#1381)

    πŸš€ This release was made possible by the work and feedback of:

    • Alexandru Nedelcu (@alexandru)
    • Dominik WosiΕ„ski (@Wosin)
    • Lars Hupel (@larsrh)
    • Luke Stephenson (@lukestephenson)
    • Oleg Pyzhcov (@oleg-py)
    • Pau AlarcΓ³n (@paualarco)
    • Piotr GawryΕ› (@Avasil)

Previous changes from v3.3.0

  • πŸš€ The release is binary and source compatible with 3.x.x line.
    πŸš€ It is released for the following Scala and ScalaJS versions:

    • Scala 2.11: ScalaJS 0.6.x
    • Scala 2.12: ScalaJS 0.6.x and 1.3.x
    • Scala 2.13: ScalaJS 0.6.x and 1.3.x

    πŸš€ Note that most likely, this is going to be the last release on ScalaJS 0.6.x.
    We can consider doing backports on-demand.


    πŸ‘ Better Stack Traces

    πŸš€ This release includes a highly requested feature of better stack traces for Task and Coeval!
    Big thanks to @RaasAhsan and @djspiewak for providing the original implementation that we have ported.

    πŸ”§ They are enabled by default, but it is configurable.
    πŸ“„ Refer to Stack Traces section for more details.

    🐎 We have measured about 10-30% performance hit in CACHED mode (the default) in microbenchmarks.
    🐎 If you have any performance tests, we would greatly appreciate any reports!
    If the hit is too big, you can disable the stack traces with -Dmonix.eval.stackTracingMode=none.

    For the following code:

    package test.appimport monix.eval.Taskimport monix.execution.Schedulerimport cats.implicits.\_import scala.concurrent.duration.\_object TestTracingApp extends App { implicit val s = def customMethod: Task[Unit] val tracingTestApp: Task[Unit] = for { \_ \<- Task.shift \_ \<- Task.unit.attempt \_ \<- (Task(println("Started the program")), Task.unit).parTupled \_ \<- customMethod \_ \<- if (true) Task.raiseError(new Exception("boom")) else Task.unit } yield () tracingTestApp.onErrorHandleWith(ex =\> Task(ex.printStackTrace())).runSyncUnsafe }

    0️⃣ The default (cached) stack trace is going to be:

    java.lang.Exception: boom
            at guarantee @$.customMethod(TestTracingApp.scala:29)
            at flatMap @$.$anonfun$tracingTestApp$4(TestTracingApp.scala:35)
            at parTupled @$.$anonfun$tracingTestApp$2(TestTracingApp.scala:34)
            at parTupled @$.$anonfun$tracingTestApp$2(TestTracingApp.scala:34)
            at flatMap @$.$anonfun$tracingTestApp$2(TestTracingApp.scala:34)
            at flatMap @$.$anonfun$tracingTestApp$1(TestTracingApp.scala:33)
            at flatMap @$.delayedEndpoint$test$app$TestTracingApp$1(TestTracingApp.scala:32)

    Before 3.3.0 and with stack traces disabled, stack traces are a mess:

    java.lang.Exception: boom
            at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:188)
            at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101)
            at monix.eval.internal.TaskRestartCallback$$anon$
            at monix.execution.internal.Trampoline.monix$execution$internal$Trampoline$$immediateLoop(Trampoline.scala:66)
            at monix.execution.internal.Trampoline.startLoop(Trampoline.scala:32)
            at monix.execution.schedulers.TrampolineExecutionContext$JVMNormalTrampoline.super$startLoop(TrampolineExecutionContext.scala:142)
            at monix.execution.schedulers.TrampolineExecutionContext$JVMNormalTrampoline.$anonfun$startLoop$1(TrampolineExecutionContext.scala:142)
            at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
            at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
            at monix.execution.schedulers.TrampolineExecutionContext$JVMNormalTrampoline.startLoop(TrampolineExecutionContext.scala:142)
            at monix.execution.internal.Trampoline.execute(Trampoline.scala:40)
            at monix.execution.schedulers.TrampolineExecutionContext.execute(TrampolineExecutionContext.scala:57)
            at monix.execution.schedulers.BatchingScheduler.execute(BatchingScheduler.scala:50)
            at monix.execution.schedulers.BatchingScheduler.execute$(BatchingScheduler.scala:47)
            at monix.execution.schedulers.AsyncScheduler.execute(AsyncScheduler.scala:31)
            at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:72)
            at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:183)
            at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101)
            at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:74)
            at monix.eval.internal.TaskSleep$
            at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(
            at java.util.concurrent.ForkJoinTask.doExec(
            at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(
            at java.util.concurrent.ForkJoinPool.runWorker(

    πŸ‘ Better Task => Future interop when using Local

    βš™ Running Task isolates Local, which was not available in the Future, resulting in runToFuture.
    πŸš€ This release enables it and unblocks compelling use cases, such as reading proper request context in Akka HTTP Directive.
    We've created an AkkaHTTP Example that demonstrates it.

    βœ… Latest behavior is:

    implicit val s: Scheduler = Scheduler.Implicits.tracedval local = Local(0)for { \_ \<- Task(local.update(1)).runToFuture value \<- Future(local.get) } yield println(s"Local value in Future $value") println(s"Local value on the current thread = $value")// =\> Local value on the current thread = 0// =\> Local value in Future = 1

    Task still isolates the Local, but the Future continuation keeps the same reference and can read it.
    Before the change, Local would be 0 in the Future.

    πŸ“š More information about Local can be found in the new Local documentation.

    ⚑️ Relevant updates

    • πŸ”€ #1205: Observable.mergePrioritizedList
    • #1209: Bring back Observable.transform and Transformer alias
    • #1198: Fix flatMapIterable calling recursively itself
    • #1213: Propagate Local isolation in runToFuture
    • 🐎 #1217: Fix performance regression in bufferSliding
    • πŸ‘ #1244: Add support for compression: Gzip and deflate
    • #1262: Fix bug in Task.runSyncUnsafe related to ContextSwitch
    • #1265: Implement Observable#bufferWhile and bufferWhileInclusive
    • #1267: Implement Asynchronous Stack Traces for Task
    • #1276: Add Task/Coeval convenience methods like .when
    • #1282: Add 'as' in Task and Coeval
    • πŸ— #1284: Add left/right builders for Task and Coeval
    • πŸ— #1286: Add none/some builders for Task and Coeval
    • #1291: tapEval, tapError methods at Task and Coeval
    • #1293: removing no-op onComplete() in Observable.takeByTimespan
    • #1299: Fix a bug in Local.value
    • #1307: Observable.fromIteratorBuffered

    πŸš€ People who made this release possible