diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/ActionsActor.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/ActionsActor.kt index 9a22f9f1cfe..10026efc74e 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/ActionsActor.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/ActionsActor.kt @@ -38,7 +38,7 @@ inline fun CoroutineScope.createSafeActionsActor( suspend fun Channel Unit>.doWithSuspending( action: ActorAction ) = suspendCoroutine { - offer { + trySend { safely({ e -> it.resumeWithException(e) }) { it.resume(action()) } diff --git a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FlowsWebsocket.kt b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FlowsWebsocket.kt index ac265170316..bd7d9a32670 100644 --- a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FlowsWebsocket.kt +++ b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/FlowsWebsocket.kt @@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.collect import kotlinx.serialization.SerializationStrategy private suspend fun DefaultWebSocketSession.checkReceivedAndCloseIfExists() { - if (incoming.poll() != null) { + if (incoming.tryReceive() != null) { close() throw CorrectCloseException }