Team #coroutines, is jobCencellationException in flow coroutines is common or how can we avoid this exception
g
gildor
09/27/2022, 3:51 PM
Could you please clarify your problem
CancellationException is completely fine by itself, is way to propagate cancellation of coroutines, including Flow
g
Gomathi Gms
09/27/2022, 3:53 PM
When am leaving viemodel with logout. Am getting jobCencellationException
c
Casey Brooks
09/27/2022, 4:06 PM
That’s normal, it’s the mechanism by which coroutines are only active as long as the ViewModel itself is active. You’re not supposed to catch that exception, or if you do you’re supposed to rethrow it to cooperate with cancellation (read more here)
Once the ViewModel is cleared, the
viewModelScope
will be cancelled so you don’t have work continuing to run the background wasting system resources.