ursus
09/11/2025, 4:13 PMprivate suspend fun DefaultClientWebSocketSession.send(outgoingSubmission: OutgoingSubmission) {
when (outgoingSubmission) {
is OutgoingSubmission.Text -> {
val outgoingEnvelope = OutgoingEnvelope.HandleMessage(
...
)
send(OutgoingEnvelope.HandleMessage.serializer(), outgoingEnvelope) <-------
}
...
}
}
detekt flags this code with suspend function uses CoroutineScope as receiver. [SuspendFunWithCoroutineScopeReceiver]
is this a false positive? what's wrong with it?
Sure ktor's DefaultClientWebSocketSession is a coroutine scope but im pretty sure it's not meant to launch sends into it?ephemient
09/11/2025, 4:27 PMCoroutineScope or be suspend, but both is usually not a good pattern, as it could allow the function to unexpectedly escape structured concurrency. in this case it doesn't seem avoidable thoughursus
09/11/2025, 4:28 PM