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

Daniel Lukic

12/13/2019, 10:56 AM
what is the best way to track down something like this? (android app)
Copy code
ime  D  Shutting down VM
     E  FATAL EXCEPTION: main
     E  Process: com.dhl.lps.consumer.debug, PID: 18730
     E  kotlinx.coroutines.JobCancellationException: Job was cancelled; job=StandaloneCoroutine{Cancelling}@48c8a44
we have scopes like
MainScope() + CxExceptionHandler(..)
with
launch { .. }
consistently. no
async
for now. so this seems to be some weird/interesting edge case.. 🙂 any pointers on how to track this thing down? 🤔
v

Vsevolod Tolstopyatov [JB]

12/13/2019, 1:12 PM
Complete stacktrace would be a great start 🙂 But most likely it is an interopability issue: all coroutines machinery generally ignores
CancellationException
. Probably you do something like
Channel.offer
from within a callback and do not catch CE
d

Daniel Lukic

12/13/2019, 1:22 PM
been debugging this all day.. it seems like it is caused by cancelling a job that contains a flow - but cancelling from within the collect body of the flow itself.. so.. not cancelling the flow from within itself.. but its surrounding job.. this randomly but most of the time crashes the app by letting the cancellation exception escape.. like.. it slips by the installed top level exception handler of the scope.. sounds weird to bad.. 😕 but still debugging..
@Vsevolod Tolstopyatov [JB] thanks for the
Channel.offer
hint.. it seems it was related to exactly this.. we wrongly assumed the callback would not trigger anymore after the cancel.. but it does.. and that's actually fine and ok.. we just didn't consider this scenario.. thanks again! 👍