Posted on

Coroutine trap from Arkadii Ivanov

Another day, another Kotlin Coroutines trap I’ve fallen into. Been using coroutines for years, still happens. And turned out I’m not the only one: https://stackoverflow.com/questions/56305044/kotlin-coroutine-withtimeout-does-not-cancel-when-using-withcontext-to-get-non-b I know that cancellation is cooperative. But for some reason I assumed that the cooperation is somehow already implemented inside `withContext`.

https://twitter.com/arkann1985/status/2113579793790943690