New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kotlinx.coroutines.JobCancellationException: FlowSubscription was cancelled #1
Comments
Might also be related to Kotlin/kotlinx.coroutines#1762. |
Hey @mhernand40, I missed the notification for this issue, sorry. Do you understand what's different in your logout flow that might be related to the issue? It'd be great if we had a minimal working example to dig deeper. |
Hi @tfcporciuncula, no worries. I have since reverted back to https://github.com/f2prateek/rx-preferences and then convert the I believe the issue is that we are subscribed to Streams from both Rx and Flow in our MainActivity. Normally when this activity gets destroyed, we dispose/cancel these streams. However, for the logout scenario, I believe our SharedPreferences get cleared before MainActivity gets destroyed, which is probably something we should fix on our end, but that's a separate issue. For some reason with Flow Preferences, we were running into a I feel that what's happening is:
I still have to come up with a minimal repro to verify what exactly is going wrong. |
I finally have a minimal repro and have confirmed that the crash still occurs with:
The repro is a race condition and it actually involves converting the Please see the attached repro app. |
Thanks @mhernand40! I'll take a look. But my initial thinking is that this might be outside of the scope of this library since it's an issue that only happens when the |
I decided that I really only require basic |
Thanks for letting me know @mhernand40. I'll keep this issue open since it might be relevant for other people using the library and will close it once there's an actual fix in place. |
Potential relevant update about this here: Kotlin/kotlinx.coroutines#974 (comment) |
Now that the underlying coroutines issue is fixed, I'm reverting the fix we have for this in favor of the new |
I recently migrated a class that uses https://github.com/f2prateek/rx-preferences to now use
FlowPreferences
. In our app, when the user logs out, we clear allSharedPreferences
. During the logout, the app is crashing with the following exception:There isn't really any more details regarding the stack trace. I suspect I am running into Kotlin/kotlinx.coroutines#974 which may make sense given
FlowSharedPreferences.keyFlow
is implemented as such:Something tells me that the
offer(key)
is being performed after theChannel
has been closed.The text was updated successfully, but these errors were encountered: