AndroidPub
AndroidPub
Jul 3, 2025 · Mobile Development

Mastering Kotlin Coroutine Cancellation: Avoid Zombie Coroutines and Hidden Bugs

This article explains how Kotlin coroutine cancellation works, why catching CancellationException can create zombie coroutines, and provides concrete patterns—using isActive, coroutineContext.ensureActive(), and proper try‑catch placement—to reliably stop repeating tasks without resource leaks.

AsyncCancellationCancellationException
0 likes · 9 min read
Mastering Kotlin Coroutine Cancellation: Avoid Zombie Coroutines and Hidden Bugs