KTConf

@ktconf.bsky.social

(/ˈkeɪti/ Kay-Tee) Conf A belgian kotlin developer conference, the second edition on Friday 18/09/2026 in Museum M, Leuven, Belgium. Hope to see you there! Website: https://ktconf.be Discord: https://discord.gg/unqnpKCJBf

Engineers, this coroutines puzzle is for you! Take a look at the code. The request failed, and requestScope.cancel() was explicitly called in onFailure. Why is the OCR engine still running in the background? You have 24 hours 😉 Check again in a day for the answer and part 2 of this challenge.

The request failed, and requestScope.cancel() was explicitly called in the onFailure block. Why is the OCR engine still running in the background?

fun processUpload(requestScope: CoroutineScope): CoroutineScope {
    val processScope = CoroutineScope(requestScope.coroutineContext + SupervisorJob())

    processScope.launch {
        while (isActive) {
            println("   Processing PDF OCR chunk...")
            delay(30.milliseconds)
        }
    }

    throw IOException("Client disconnected!")
}

fun main() = runBlocking {
    val requestScope = 
            CoroutineScope(Dispatchers.Default + Job())

    runCatching {
        processUpload(requestScope)
    }.onFailure {
        println("Client disconnected")
        requestScope.cancel()
    }

    delay(1000.milliseconds)
}

A) requestScope.cancel() wasn't called in 
     time.
B) SupervisorJob severed the parent-child 
    cancellation link.
C) runCatching swallowed the 
    CancellationException.
D) while (isActive) does