https://kotlinlang.org logo
Title
m

Mickey Donaghy

08/25/2021, 8:49 AM
hi, if I cancel a coroutine 
Job
 is there a way to find out where it was stuck? I can pass a 
CancellationException
 in, but what I really want is a traceback for where it was when it got cancelled.
e

ephemient

08/25/2021, 9:13 AM
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-debug/index.html can print out the state of a Job (among other things)
m

Mickey Donaghy

08/25/2021, 9:38 AM
hmm, that seems to only show the topmost suspension point of the job, is that right?
maybe it's an optimization - if the function suspends immediately then only the top suspension point is recorded or something? If I add a
delay(Duration.ZERO)
to my low-level function then I get the right result
thanks for the pointer!