I have posted about this before and didn't get any...
# coroutines
t
I have posted about this before and didn't get anywhere. The problem still persists and is quite unpredictable. Does anyone have any suggestion on how I might even start to tackle this? Some way to debug it? I couldn't get
handleFatalException
to yield anything particularly helpful. I managed to get a more detailed exception trace by enabling coroutine debug mode:
Copy code
Exception in thread "DefaultDispatcher-worker-11" kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[Dispatchers.Default, Continuation at io.ktor.client.HttpClient.execute$ktor_client_core(HttpClient.kt:191)@4b98bc73]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
	at kotlinx.coroutines.DispatchedTask.handleFatalException(DispatchedTask.kt:144)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:115)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [CoroutineId(546), "coroutine#546":StandaloneCoroutine{Completed}@73f0a21a, Dispatchers.Default]
Caused by: java.lang.ClassCastException: class kotlin.coroutines.jvm.internal.CompletedContinuation cannot be cast to class kotlinx.coroutines.internal.DispatchedContinuation (kotlin.coroutines.jvm.internal.CompletedContinuation and kotlinx.coroutines.internal.DispatchedContinuation are in unnamed module of loader 'app')
	at kotlinx.coroutines.CoroutineDispatcher.releaseInterceptedContinuation(CoroutineDispatcher.kt:166)
	at kotlin.coroutines.jvm.internal.ContinuationImpl.releaseIntercepted(ContinuationImpl.kt:118)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:39)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	... 4 more
As for versions, I am running Kotlin 1.8.20, kotlinx.coroutines 1.7.1 and Ktor 2.3.0.
c
Maybe try #ktor
f
It’s been fixed in newer versions of ktor. The one you’re using is rather old https://youtrack.jetbrains.com/issue/KTOR-906/Unhandled-exception-caught-for-CoroutineNamehttp-pipeline-writer