RBusarow/Dispatch

dispatchLifecycleScope.kt sometimes fails to catch FlowCancellationException

Closed this issue · 0 comments

Fatal Exception: java.lang.RuntimeException: Unable to pause activity {*******Activity}: dispatch.android.lifecycle.internal.FlowCancellationException: Flow was aborted
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4124)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4090)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4064)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4038)
       at android.app.ActivityThread.-wrap16()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1708)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6938)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by dispatch.android.lifecycle.internal.FlowCancellationException: Flow was aborted
       at dispatch.android.lifecycle.internal.DispatchLifecycleScopeKt$onNext$2.invokeSuspend(dispatchLifecycleScope.kt:61)
       at dispatch.android.lifecycle.internal.DispatchLifecycleScopeKt$onNext$2.invoke(:10)
       at dispatch.android.lifecycle.internal.DispatchLifecycleScopeKt$onEachLatest$1.invokeSuspend(dispatchLifecycleScope.kt:146)
       at dispatch.android.lifecycle.internal.DispatchLifecycleScopeKt$onEachLatest$1.invoke(:12)
       at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$invokeSuspend$$inlined$collect$1$lambda$1.invokeSuspend(Merge.kt:34)
       at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$invokeSuspend$$inlined$collect$1$lambda$1.invoke(:10)
       at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
       at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:111)
       at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:158)
       at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
       at kotlinx.coroutines.BuildersKt.launch(:1)
       at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:49)
       at kotlinx.coroutines.BuildersKt.launch$default(:1)
       at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$invokeSuspend$$inlined$collect$1.emit(Collect.kt:138)
       at kotlinx.coroutines.flow.DistinctFlowImpl$collect$$inlined$collect$1.emit(Collect.kt:137)
       at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)
       at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(:4)
       at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:77)
       at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:59)
       at dispatch.core.FlowKt$flowOnMainImmediate$1$invokeSuspend$$inlined$collect$1.emit(Collect.kt:133)
       at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:61)
       at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(:11)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
       at dispatch.android.espresso.IdlingDispatcher$dispatch$$inlined$Runnable$1.run(Runnable.kt:21)
       at android.os.Handler.handleCallback(Handler.java:789)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6938)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)