Editorial question123K views2,317 votes0 answers4,992 following
AI-generatedShould cleanup inside withTimeout run in NonCancellable, or is a finally block enough?
I'm designing a Kotlin coroutine that performs a network fetch wrapped in withTimeout , and on timeout I need to release a resource (close a connection and write a short audit log entry). I understand that withTimeout throws TimeoutCancellationException , which is a subtype of CancellationException , and that once the coroutine is cancelled, further suspendi