Kotlin coroutines when firstOrNull called AbortFlowException throwed

As in title I am calling firstOrNull in flow object. Below logs printed in iOS.

kotlinx.coroutines.flow.internal.AbortFlowException: Flow was aborted, no more elements needed
    at 0   KMP Base Module.debug.dylib         0x107f01173        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 119 
    at 1   KMP Base Module.debug.dylib         0x107efa63b        kfun:kotlin.Exception#<init>(kotlin.String?){} + 115 
    at 2   KMP Base Module.debug.dylib         0x107efa85b        kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 115 
    at 3   KMP Base Module.debug.dylib         0x107efad73        kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} + 115 
    at 4   KMP Base Module.debug.dylib         0x107f08783        kfun:kotlin.coroutines.cancellation.CancellationException#<init>(kotlin.String?){} + 115 
    at 5   KMP Base Module.debug.dylib         0x10817c1a3        kfun:kotlinx.coroutines.flow.internal.AbortFlowException#<init>(kotlin.Any){} + 95 
    at 6   KMP Base Module.debug.dylib         0x10814d65f        kfun:kotlinx.coroutines.flow.object-52.emit#internal + 279 
    at 7   KMP Base Module.debug.dylib         0x108188997        kfun:kotlinx.coroutines.flow.FlowCollector#emit#suspend(1:0;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any-trampoline + 115 
    at 8   KMP Base Module.debug.dylib         0x10817c7a7        kfun:kotlinx.coroutines.flow.internal.SafeCollector#emit#suspend(1:0;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any + 431 
    at 9   KMP Base Module.debug.dylib         0x108188997        kfun:kotlinx.coroutines.flow.FlowCollector#emit#suspend(1:0;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any-trampoline + 115 
    at 10  KMP Base Module.debug.dylib         0x1075e875b        kfun:com.easymoneycorp.kmpbasemodule.network.ApiService.$updateTodo$lambda$4$lambda$3COROUTINE$1.invokeSuspend#internal + 2635 
    at 11  KMP Base Module.debug.dylib         0x108040db7        kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any?-trampoline + 71 
    at 12  KMP Base Module.debug.dylib         0x107f06aeb        kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 647 
    at 13  KMP Base Module.debug.dylib         0x108040ea3        kfun:kotlin.coroutines.Continuation#resumeWith(kotlin.Result<1:0>){}-trampoline + 99 
    at 14  KMP Base Module.debug.dylib         0x108154953        kfun:kotlinx.coroutines.DispatchedTask#run(){} + 1895 
    at 15  KMP Base Module.debug.dylib         0x10818462f        kfun:kotlinx.coroutines.Runnable#run(){}-trampoline + 91 
    at 16  KMP Base Module.debug.dylib         0x10817f09b        kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.dispatch$lambda$0#internal + 119 
    at 17  KMP Base Module.debug.dylib         0x10817f0f7        kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.$dispatch$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 71 
    at 18  KMP Base Module.debug.dylib         0x10817f1c7        kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.$dispatch$lambda$0$FUNCTION_REFERENCE$0.$<bridge-DNN>invoke(){}#internal + 71 
    at 19  KMP Base Module.debug.dylib         0x10803e12b        kfun:kotlin.Function0#invoke(){}1:0-trampoline + 99 
    at 20  KMP Base Module.debug.dylib         0x108180e23        _6f72672e6a6574627261696e732e6b6f746c696e783a6b6f746c696e782d636f726f7574696e65732d636f72652f6f70742f6275696c644167656e742f776f726b2f343465633665383530643563363366302f6b6f746c696e782d636f726f7574696e65732d636f72652f6e617469766544617277696e2f7372632f44697370617463686572732e6b74_knbridge8 + 203 
    at 21  libdispatch.dylib                   0x1801774eb        _dispatch_call_block_and_release + 23 
    at 22  libdispatch.dylib                   0x180178ddf        _dispatch_client_callout + 15 
    at 23  libdispatch.dylib                   0x18017c337        _dispatch_queue_override_invoke + 1379 
    at 24  libdispatch.dylib                   0x18018b517        _dispatch_root_queue_drain + 363 
    at 25  libdispatch.dylib                   0x18018bf5f        _dispatch_worker_thread2 + 231 
    at 26  libsystem_pthread.dylib             0x104867b37        _pthread_wqthread + 223 
    at 27  libsystem_pthread.dylib             0x104866933        start_wqthread + 7 

When I inspected the source code its like below code. I just wonder am I doing something wrong? I don’t wanna see this exception log in logCat.

 val collector = object : FlowCollector<T> {
        override suspend fun emit(value: T) {
            // Note: we are checking predicate first, then throw. If the predicate does suspend (calls emit, for example)
            // the resulting code is never tail-suspending and produces a state-machine
            if (!predicate(value)) {
                throw AbortFlowException(this)
            }
        }
    }
    try {
        collect(collector)
    } catch (e: AbortFlowException) {
        e.checkOwnership(collector)
    }

New contributor

Mobile Dev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật