Hello everyone. Hope you are all doing well. I am ...
# moko
d
Hello everyone. Hope you are all doing well. I am working with
moko-mvvm
library and am using their
dev.icerock.moko.mvvm.viewmodel.ViewModel
Of course, inside of it there is its own
viewmodelScope
I am encountering an error where
viewmodelScope
is getting cancelled and the
CoroutineExceptionHandler
is not working properly Here is a small sample
Copy code
class MyViewModel: ViewModel() {
    init {
        viewModelScope.coroutineContext[Job]?.invokeOnCompletion {
            Logger.e { "Viewmodel scope finished lol what the heck " }
        }
    }
    fun foo(){
        viewModelScope.launch(
            CoroutineExceptionHandler { _, throwable: Throwable ->
                Logger.e(throwable) { "foo failed" }
            }
        ) {
            throw Exception("ohoh")
    }
}
When user calls
foo
and it of course fails due to the thrown exception,
invokeOnCompletion
shouldn't be called, but it is called. Am I doing something wrong but as far as I know coroutines, after installing a coroutine exception handler on a coroutine it shouldn't cancel the scope 🤷, is this a viewmodelScope a
SupervisorJob
or not, I don't think that even the normal scope should be cancelled in this case?
Okay, I see that there is an open issue here
I added couple of comments. Is someone planning to resolve this issue?
anyone??