Open
Description
Originally reported by Uli Luckas in the Kotlinlang Slack: https://kotlinlang.slack.com/archives/C1CFAFJSK/p1742815571506039?thread_ts=1742814326.569149&cid=C1CFAFJSK
The caveat with how withContext
may drop closeable resources (#3504) should be highlighted in the guide:
val socket = withContext(Dispatchers.IO) {
Socket("localhost", 8080)
} // CancellationException can be thrown here, after the resource gets created
socket.use {
// ...
}
The same goes for prompt cancellation guarantees in the other APIs.