kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

Coroutine is not visible in DebugProbes if it was not suspended

Open dovchinnikov opened this issue 3 years ago • 0 comments
trafficstars

JVM: Liberica 11.0.14.1 kotlinx-coroutines-jdk8 1.6.2 kotlinx-coroutines-debug 1.6.2

The following program

import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.debug.DebugProbes
import kotlinx.coroutines.launch

fun main() {
  DebugProbes.enableCreationStackTraces = false
  DebugProbes.install()
  GlobalScope.launch {
    launch {
      awaitCancellation()
    }
  }
  Thread.sleep(100)
  DebugProbes.dumpCoroutines()
  println()
  println("-----")

  for (coroutineInfo in DebugProbes.dumpCoroutinesInfo()) {
    println(coroutineInfo)
  }
}

prints

Coroutines dump 2022/07/28 16:04:10

Coroutine "coroutine#2":StandaloneCoroutine{Active}@49070868, state: SUSPENDED
	at kotlinx.coroutines.DelayKt.awaitCancellation(Delay.kt:148)
	at com.intellij.diagnostic.DebugprobestestKt$main$1$1.invokeSuspend(debugprobestest.kt:14)
-----
CoroutineInfo(state=SUSPENDED,context=[CoroutineId(2), "coroutine#2":StandaloneCoroutine{Active}@49070868, Dispatchers.Default])

I'd expect to see the root coroutine somewhere in the dump, it "hangs" because its child is not completed.

dovchinnikov avatar Jul 28 '22 14:07 dovchinnikov