Debuggable async/await
hordon opened this issue · 3 comments
All we know that code in async block cannot be debugged properly with IDE because they don't support async/await library yet. This issue can be easily fixed by creating stub library "org.scala-lang.modules" %% "scala-async-debug" % "1.0.0"
that can be replaced from scala-async
library when you need to debug your application. Why wouldn't provide this feature ?
The stub snippet looks very simple but can provide the ability to debug the application:
package scala.async
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, ExecutionContext, Future}
object Async {
def async[T](body: T)(implicit execContext: ExecutionContext) = Future(body)
def await[T](awaitable: Future[T]) = Await.result(awaitable, Duration.Inf)
}
An alternative would be to emit such code from the regular async macro when a compiler option is provided. (-Xmacro-settings:scala.async.blocking
)
BTW, IntelliJ has recently added some support in their debugger for async (evaluate expression knows that local variables in an async block might be translated to name mangled fields in a state machine class).
What specific debugging limitations are you referring to?