scala/scala-async

Why I cannot debug a code in async block in intellij

lahirug opened this issue · 6 comments

Anybody noticed this and found a workaround ?

Yes I have the same problem, but It doesn't happen every time.

I noticed this. Annoying as hell. Actually this is probably number 1 on my priority list. This and error handling.

Yes. Its very annoying. We used Play framework and everything is written within async block. It happens always for me.

I see that the IntelliJ Scala Plugin team has just added some support for scala-async to the debugger.

JetBrains/intellij-scala@64774de
JetBrains/intellij-scala@ff04b9f

The bug report, SCL-9039, seems the be reporting the same problem you're discussing here.

As a nice bonus, @niktrop seems to have added special support in "evaluate expression" so that local variables in the user-written code are retrieved from the corresponidng name-mangled fields of the state machine class. Thanks!

@niktrop Let me know if there is anything we can do in the macro to make your life easier here..

@lahirug @efiko12 @pkolaczk @worldofprasanna Thanks for your patience with this problem. Could I ask you to test out the latest nightly of the Scala Plugin (this requires use of IDEA 15) and report whether the situation is improved?

There are some problems with availability of local variables and fields. Try this example:

object AsyncBugs {
  def main(args: Array[String]) {
    val future = async {
      val f1 = async { false }
      val f2 = async { 42 }
      if (await(f1))
        await(f2)
      else {
        "Hi" //breakpoint here
      }
    }

    Await.result(future, Duration.Inf)
  }
}

Field, generated for f2 is already null. And local variable f1 is not visible from the breakpoint location. I suppose wrong debug info for local variable table is generated.

With the recent plugin I can put a breakpoint inside of async block and now it properly stops there. However, I noticed I can't step over await calls. Much better than before, but still needs more work.