ktor icon indicating copy to clipboard operation
ktor copied to clipboard

java.lang.IllegalStateException: Flow invariant is violated

Open annotation-engine opened this issue 6 months ago • 1 comments

java.lang.IllegalStateException: Flow invariant is violated: Flow was collected in [io.ktor.server.engine.DefaultUncaughtExceptionHandler@359055aa, CoroutineName(call-handler), io.ktor.server.netty.NettyDispatcher$CurrentContext@37e53b74, ScopeCoroutine{Active}@3128cf23, io.ktor.server.application.ClassLoaderAwareContinuationInterceptor@4a9bb1d0], but emission happened in [io.ktor.server.engine.DefaultUncaughtExceptionHandler@359055aa, CoroutineName(call-handler), io.ktor.server.netty.NettyDispatcher$CurrentContext@37e53b74, ScopeCoroutine{Active}@3128cf23, io.ktor.server.application.ClassLoaderAwareContinuationInterceptor@4a9bb1d0]. Please refer to 'flow' documentation or use 'flowOn' instead at kotlinx.coroutines.flow.internal.SafeCollector_commonKt.checkContext(SafeCollector.common.kt:84) at kotlinx.coroutines.flow.internal.SafeCollector.checkContext(SafeCollector.kt:132) at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:109) at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:82) at io.ktor.http.content.MultipartKt$asFlow$1.invokeSuspend(Multipart.kt:145) at io.ktor.http.content.MultipartKt$asFlow$1.invoke(Multipart.kt) at io.ktor.http.content.MultipartKt$asFlow$1.invoke(Multipart.kt) at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:57)

annotation-engine avatar Jun 13 '25 04:06 annotation-engine

This worked normally in 3.1.3, but after upgrading to 3.2.0, there was a problem with a regular interface

annotation-engine avatar Jun 13 '25 04:06 annotation-engine

I'm seeing this as well, it looks like ApplicationCall.receiveMultipart().forEachPart(){} is enough to trigger it

Tak avatar Jun 23 '25 09:06 Tak

Thank you for the report! Please, track this issue in YouTrack:

  • KTOR-8606 Regression in 3.2.0: Flow invariant is violated

osipxd avatar Jun 23 '25 10:06 osipxd