question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CoroutinesInternalError - Job is already complete or completing

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Samhithgbcommented, Sep 18, 2020

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()

0reactions
ReginFellcommented, Oct 7, 2020

Any news related to this issue? combine is completely unreliable since it randomly crashes on some android devices

Read more comments on GitHub >

github_iconTop Results From Across the Web

kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast ...
CoroutinesInternalError : Fatal exception in coroutines machinery for ... is already complete or completing, but is being completed with ...
Read more >
Thread starting during runtime shutdown : KT-48306
CoroutinesInternalError : Fatal exception in coroutines machinery for DispatchedContinuation - Thread starting during runtime shutdown : KT-48306.
Read more >
complete
Completes this job. The result is true if this job was completed as a result of this invocation and false otherwise (if it...
Read more >
WhatsNew 1.5 | Ktor Framework
JobCancellationException: Parent job is Completed; ... Selecting custom package name in Ktor wizard still results in example.com import in ...
Read more >
Measuring execution time in Kotlin coroutines | Blog | bol.com
Or if you do, please make sure you finish reading this blog post after ... CoroutinesInternalError: Fatal exception in coroutines machinery ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found