kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

Inconsistent behavior between `withContext` and `withTimeout`/`coroutineScope`/`supervisorScope` if the caller is cancelled before the start

Open dkhalanskyjb opened this issue 5 months ago • 0 comments
trafficstars

runBlocking {
    cancel()
    withContext(EmptyCoroutineContext) {
        println("This will not be printed")
    }
    println("Neither will this")
}
runBlocking {
    cancel()
    withTimeout(1.seconds) {
        println("This will be printed")
    }
    println("This will not")
}

dkhalanskyjb avatar Jun 13 '25 09:06 dkhalanskyjb