I keep hitting those exceptions in one of my scope...
# coroutines
p
I keep hitting those exceptions in one of my scope.launch { } blocks
kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled;
Is there a way to know where this cancellation is coming from? I've put logging+breakpoints everywhere I manually cancel the job, but it's coming from somewhere else..?
f
Are you launching another Coroutine in this scope. I believe this can happen if you try to launch a new Coroutine after the scope is cancelled.
p
I'm using
launch
and
withContext
in that scope, yes
f
It is hard to tell without a code but where are you cancelling the scope?
p
outside the whole thing
c
If one job has an error, all its parent jobs are then cancelled. When a job is cancelled, it also cancels all its children. Thus, if a single job has an error, the entire tree of jobs is cancelled. You’ll probably want to to use a supervisorScope to manage independent parallel tasks https://kotlinlang.org/docs/reference/coroutines/exception-handling.html#supervision
p
I have an eventbus event, and when it receives a certain type of event it cancels the job
returned from the launch function
gotcha
I'll try that