java.lang.IllegalStateException: Flow invariant is violated
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)
This worked normally in 3.1.3, but after upgrading to 3.2.0, there was a problem with a regular interface
I'm seeing this as well, it looks like ApplicationCall.receiveMultipart().forEachPart(){} is enough to trigger it
Thank you for the report! Please, track this issue in YouTrack:
- KTOR-8606 Regression in 3.2.0: Flow invariant is violated