Coroutine Scope Never Cancelled (ARCH8034)
Esta página aún no está disponible en tu idioma.
Key kotlin.async.coroutine-scope-never-cancelled · Severity warning · Category async
Flags a CoroutineScope or Job created as a property that the class never cancels - every coroutine launched on it outlives the owner.
Incorrect
Section titled “Incorrect”class Repo { private val scope = CoroutineScope(Dispatchers.IO) }Correct
Section titled “Correct”class Repo : Closeable { private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) override fun close() = scope.cancel()}Cancel the scope in close() / onCleared() / onDestroy(), or use a lifecycle-bound scope.