-
-
Notifications
You must be signed in to change notification settings - Fork 908
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
Stream ending with BadState when navigating back and forth quickly #3485
Comments
I am attaching the demo video. If you look carefully you will see that I get a bad stream error only when I quickly navigate to accounts page from home page (I got to home page form accounts page by back gesture on my device). It works fine on normal navigation speed. file.mp4Just as a note, I have |
Just filling in, it looks like the stream is being listened twice, which a singleuser stream cannot. But the puzzle is why doesn't the provider fully recycle during the quick back and forth, which would have created a new stream? |
@RandalSchwartz exactly! I am curious why the provider does not fully recycle during quick back and forth. |
There's too much code here. I can't realistically investigate a whole project. Please create a minimal reproducible example. But my guess is, this is most likely a mistake on your end. I'd suggest asking for help on Discord |
@rrousselGit thanks for letting me know about it. I apologize for having a bit more code for a minimal sample. I hope the new code changes are simple to catch and understand. Have a look at it at your convenience. Also, I have tried asking for help on Discord before I filed an issue. It could be a mistake from my end but I can't figure out where I am going wrong with this. |
As a follow-up, I noticed that when I converted AccountsPage to |
I recently pushed a new branch called As a note, the file |
It seems like I have to |
Describe the bug
I have an app where there is a button in the home page. Upon clicking the button, it navigates me to accounts list page which are retrieved from a local database query stream. When I go to accounts page and come back, everything works fine. However, if I immediately go to accounts page as soon as I am back to home page, it throws me
BadState: Stream has already been listened to
error. Upon investigating, I found that it takes about a second to cleanup the provider state. Meaning, if I navigate do not navigate quickly to accounts page from home, it works fine.I tried it with two different databases -
Isar
andObjectBox
. Both of them were having the same behaviour. If I remove the provider and manually get the stream, it works fine because the widget lifecycle disposes of the stream as soon as I go back (pop the navigation stack).To Reproduce
I am attaching a sample project with instructions on the home page to reproduce the bug.
https://github.com/AxelBlaz3/Riverpod-StreamBuilder-Bug
Expected behavior
Riverpod should clean up the provider state immediately after I pop the current page because there are no listeners after popping the current page. However, it takes about a second to clean things up which is not what I am expecting (but correct me if I am mistaken).
The text was updated successfully, but these errors were encountered: