liujingxing / rxhttp

🔥🔥🔥 Based on OkHttp encapsulation, support Kotlin Coroutines、RxJava2、RxJava3; 30s to get started.
https://juejin.im/post/5ded221a518825125d14a1d4
Apache License 2.0
3.74k stars 457 forks source link

关于kotlinx.coroutines.JobCancellationException: Job was cancelled #462

Closed berial closed 1 year ago

berial commented 1 year ago

页面上有多个tab,快速切换时会报 kotlinx.coroutines.JobCancellationException: Job was cancelled; job=JobImpl{Cancelling}@bbb1315。 请求代码为:

if (job != null && job?.isActive == true) 
    job?.cancel()
    job = runBlocking {
        repo.fetchData().onEach{ xxxxxx }.collect() // 一个网络请求转flow
    }

不影响使用,但是会打印一个tag为Rxhttp的error日志,请问该如何解决?

liujingxing commented 1 year ago

这是正常的,页面关闭,协程会关闭,请求也会跟着关闭,也就有了这个异常。 目前如果不想看到,只能通过setDebug(false)方法关闭日志输出