-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
viewModelScope.launch {...} not executed again when exception occurred #249
Comments
This is happening to me as well in a similar way, did you manage to find a solution around this? |
The only way I found was the one I mentioned above. Use |
CauseThe mvvm.viewmodel viewModelScope context does not include a SupervisorJob() which means if the job executed through viewModelScope is canceled, its child jobs will also be canceled. Solution
|
I have the similar issue. Using |
This is not the solution. It is highly discouraged to use custom Here Roman Elizarov's article about it in more depth |
If you use
viewModelScope.launch {}
with aCoroutineExceptionHandler
and an exception occurs, the same function does not run anymore when triggered again.Repro
(
Logger
is fromimplementation("co.touchlab:kermit:2.0.0-RC5")
)The
doSomething
function is triggered on compose button click. First run outputs as expected:If you then click the button again, only
Trying to do something...
appears, so theviewModelScope.launch
is not executed anymore.If you change the
doSomething()
function to useCoroutineScope
directly, everything works as expected:The text was updated successfully, but these errors were encountered: