You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val job =Job()
val actor = actor<Int>(job, Channel.UNLIMITED) {
consumeEach {
println(it)
}
}
job.cancel()
actor.offer(1)
The last line (offer) causes this exception:
kotlinx.coroutines.JobCancellationException: Job was cancelled; job=JobImpl{Cancelled}@8c661fc
at kotlinx.coroutines.JobSupport.createJobCancellationException(JobSupport.kt:615)
at kotlinx.coroutines.JobSupport.createCauseException(JobSupport.kt:640)
at kotlinx.coroutines.JobSupport.cancelMakeCompleting(JobSupport.kt:604)
at kotlinx.coroutines.JobSupport.cancelImpl(JobSupport.kt:592)
at kotlinx.coroutines.JobSupport.cancel(JobSupport.kt:575)
at kotlinx.coroutines.JobSupport.cancel(JobSupport.kt:570)
at cz.masterapp.annie2.coroutines.JobTest$test$1.invokeSuspend(JobTest.kt:25)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.kt:116)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:76)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:53)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at cz.masterapp.annie2.coroutines.JobTest.test(JobTest.kt:16)
One would typically look at JobTest.kt:25, but on line 25 is actualy the cancel() call, making the problematic offer untracable. 😿
In practice, the offers and cancels might be in different files/classes and good luck searching which offer is the cause.
The text was updated successfully, but these errors were encountered:
From what I see in the code, the kotlinx.coroutines.stacktrace.recovery is enabled by default, if you have kotlinx.coroutines.debug enabled. Which I have, and still gets this useless stack trace.
Maybe I should look att the kotlinx-coroutines-debug module, but it's something completely new for me, and from the readme, it doesn't even say anything about better exception handling.
Let's have this very simplified code:
The last line (
offer
) causes this exception:One would typically look at JobTest.kt:25, but on line 25 is actualy the
cancel()
call, making the problematicoffer
untracable. 😿In practice, the offers and cancels might be in different files/classes and good luck searching which
offer
is the cause.The text was updated successfully, but these errors were encountered: