https://kotlinlang.org logo
Title
t

Tolriq

11/18/2020, 7:40 AM
Documentation of SharedFlow says:
All methods of shared flow are *thread-safe* and can be safely invoked from concurrent coroutines without external synchronization.
But IDE on SharedFlow.emit says:
Collects the value emitted by the upstream. This method is not thread-safe and should not be invoked concurrently.
Which one is right?
e

elizarov

11/18/2020, 8:03 AM
The first one is right. We really need to override the docs on
SharedFlow.emit
t

Tolriq

11/18/2020, 8:06 AM
Thanks that's what I supposed but better to be sure.
e
t

Tolriq

11/18/2020, 9:07 AM
Since you are here sorry to ask but can you confirm that https://github.com/Kotlin/kotlinx.coroutines/pull/2377 was only an issue when there was already a ongoing unhandled exception but else 1.4.1 is safe to use?
e

elizarov

11/18/2020, 9:09 AM
I really don't know. I did not have time to create a proper test, so it is all kind of tentative. I would be grad if you can minimize a problem and turn into a self-contained test, then we can really verify that this PR fixes it.
(without a test I can only say that it definitely does not harm)
t

Tolriq

11/18/2020, 9:16 AM
I tried a lot to reproduce but was unable 😞 All I know is that with 1.3.9 and tons of DAU I see about 1 or 2 times per week an coroutine internal machinery error with the code reported at https://github.com/Kotlin/kotlinx.coroutines/issues/2371#issuecomment-725927734