The ktor `tls` function takes a `coroutineContext`...
# ktor
r
The ktor
tls
function takes a
coroutineContext
parameter (https://api.ktor.io/ktor-network/ktor-network-tls/io.ktor.network.tls/tls.html) -- what is the intended usage pattern for this? When the TLS handshake fails the exception is propagating up my coroutine tree as unhandled exceptions, even though I catch it in the child coroutine. Only passing an independent scope to
socket.tls()
appears to prevent this propagation -- is that the recommended approach?
For now, I've created a separate scope, which is not a child of the scope that starts the socket. I cancel this scope when the socket is closed.
@Aleksei Tirman [JB] Any thoughts here?
e
This
coroutineContext
will receive errors when there are no other handlers to process it (for instance in case of shutdown). You also can use it for the cancellation. You rarely can use it as a child cause usually socket coroutine is not decomposition of your parent task
r
Thank you @e5l. That makes sense. It would be useful if the docs for the tls method would discuss this.
e
Thank you! That's really fast. Merged
👍 1