https://kotlinlang.org logo
#coroutines
Title
# coroutines
n

Niklas Gürtler

02/08/2021, 12:02 PM
When I catch a
CancelledException
from a Coroutine, can I find out where the cancel originated from? Some of my coroutines are spuriously cancelled and I'm trying to find out why 🤔
g

gildor

02/08/2021, 1:52 PM
Yes, same as any other exception, but make sure that you enabled debug mode of coroutines, it will enable stacktrace recovery, so there is higher chance that your will get useful info from cancellation exception
n

Niklas Gürtler

02/08/2021, 4:00 PM
Thanks, unfortunately Coroutine debuggin seems to be unavailable on Android...
g

gildor

02/09/2021, 2:01 AM
No, it’s available,. you are talking about Debug Agent, which is based on Java Agent API and not available on Android, just enable debug mode, it’s just a runtime feature: https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/debugging.md#debug-mode
n

Niklas Gürtler

02/09/2021, 10:46 AM
Hm, stacktraces didn't change... But I found the bug by other means, so thanks anyways 😄
2 Views