Skip to content

Job.cancel() doesn't dispose SingleSource called via rx2 await() #1671

@CarsonRedeye

Description

@CarsonRedeye

I have a presenter that implements CoroutineScope and uses a SupervisorJob as the scope job.

Within that presenter, I create a long running network request like this:

launch {
    withContext(Dispatchers.IO) {
        repo.downloadThing(thingId)
    }
}

Then I quickly cancel the job in the onDestroy function of my presenter

fun destroy() {
    supervisorJob.cancel()
}

My SingleSource isn't disposed:

suspend fun downloadThing(thingId: String) {
    service.download(thingId)
                .doOnDispose { Timber.d("DISPOSED") } // This is never called
                .doOnError { Timber.d("ERROR") } // This is called only after the network call completes (leaked)
                .await()
}

Using version 1.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions