kotlinx.coroutines: CoroutinesInternalError - Job is already complete or completing
I have updated to the latest version of coroutines 1.3.3 and weird crash started popping in crashlytics. The weird thing is that all crashes are happening only on devices with Android 7.0 (about 5.5 % of users) and another common thing for these devices seems to be MediaTek SoC.
It seems to have someting to do with combine so I will look into that. Any help is appreciated
Fatal Exception: kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[LimitingDispatcher@afe7038[dispatcher = DefaultDispatcher], Continuation at kotlinx.coroutines.flow.internal.CombineKt$combineInternal$2$invokeSuspend$$inlined$select$lambda$2@f78b196]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
at kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx_coroutines_core + 278(DispatchedTask.java:278)
at kotlinx.coroutines.DispatchedTask.run + 249(DispatchedTask.java:249)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely + 594(CoroutineScheduler.java:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely + 60(CoroutineScheduler.java:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run + 740(CoroutineScheduler.java:740)
Caused by java.lang.IllegalStateException: Job ScopeCoroutine{Completed}@c55549b is already complete or completing, but is being completed with kotlin.Unit
at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core + 788(JobSupport.java:788)
at kotlinx.coroutines.AbstractCoroutine.resumeWith + 111(AbstractCoroutine.java:111)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith + 46(BaseContinuationImpl.java:46)
at kotlinx.coroutines.selects.SelectBuilderImpl.resumeWith + 254(SelectBuilderImpl.java:254)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith + 46(BaseContinuationImpl.java:46)
at kotlinx.coroutines.DispatchedTask.run + 241(DispatchedTask.java:241)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely + 594(CoroutineScheduler.java:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely + 60(CoroutineScheduler.java:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run + 740(CoroutineScheduler.java:740)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (4 by maintainers)
Commits related to this issue
- ~more small optimizations * Do not allocate array on each transform call in combine, do it only for combineTransform * Simplify zip operator even further * Get rid of crossinline in combi... — committed to Kotlin/kotlinx.coroutines by qwwdfsad 4 years ago
- Combine and zip rework (#2308) * Rework Flow.zip operator: improve its performance by 40%, collect one of the upstreams in the same coroutine as emitter * Rework Flow.combine * Get rid of t... — committed to Kotlin/kotlinx.coroutines by qwwdfsad 4 years ago
FYI, Had the same issue when running unit test on Android, and using a single thread test dispatcher fixed the issue for me :
private val testDispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()during setup :
Dispatchers.setMain(testDispatcher)and then in tear up :
Dispatchers.resetMain() testDispatcher.close()