Rob Hurkes

11/13/2020, 7:41 PM
Hey all! Anyone come across this issue with ktor 1.4+ yet? Using Jackson content negotiation, JSON response objects greater than 4kb in size throw an exception
Exception in thread "eventLoopGroupProxy-3-6" kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[UnsafeBlockingTrampoline@762b17ae, Continuation at <|>.jvm.javaio.OutputAdapter$loop$1.loop(Blocking.kt:311)@64588a54]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
. The actual cause is further down the stack trace:
Caused by: java.lang.ClassCastException: class kotlin.coroutines.jvm.internal.CompletedContinuation cannot be cast to class kotlinx.coroutines.DispatchedContinuation (kotlin.coroutines.jvm.internal.CompletedContinuation and kotlinx.coroutines.DispatchedContinuation are in unnamed module of loader 'app')
	at kotlinx.coroutines.CoroutineDispatcher.releaseInterceptedContinuation(CoroutineDispatcher.kt:103)
I've got a minimal reproduction example up at
It's similar to some other issues I've seen, but I'm not using coroutines in my app code at all, and the reproduction is rather simple. I don't mind filing a youtrack ticket for this, but wanted to check here first.
Appears to be related to this commit from 1.4.2: For some reason larger responses that go through
are ending up tying to
which leads to this exception
java.lang.UnsupportedOperationException: Parking is prohibited on this thread. Most likely you are using blocking operation on the wrong thread/dispatcher that doesn't allow blocking. Consider wrapping you blocking code withContext(<http://Dispatchers.IO|Dispatchers.IO>) {...}.
because this work (regardless of size) ends up running through a
I'm assuming that exception is what's bringing this
into the mix.
Maybe a missed call to
? Hard to say, debugging threading issues isn't my bread and butter 😅