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
FutureProvider/AsyncNotifier loses previous value when its rebuild resulting in AsyncError #1862
Comments
I can see the same behavior. If it helps, I noticed that |
Looking at the source, in my case which is an
AsyncLoading<T>()
.copyWithPrevious(previous, isRefresh: !shouldClearPreviousState),
set state(AsyncValue<T> newState) {
// TODO assert Notifier isn't disposed
newState.when(
error: _errorTransition,
loading: _loadingTransition,
data: _dataTransition,
);
if (newState.isLoading) {
setState(newState.copyWithPrevious(requireState, isRefresh: false));
} else {
setState(newState);
}
} Well it's for manual set state. I still tried to put breakpoint at the 2 setState, but no hit... So I guess a call to |
@roubachof Thanks for clarifying! That's what I was thinking too |
There is a bug in riverpod, the AsyncError doesn't get the value from the previous state. Ref: rrousselGit/riverpod#1862
Describe the bug
When FutureProvider/AsyncNotifier rebuilds because of
Ref.watch/Ref.Refresh
and resulting inAsyncError
, It loses its previous data (value
will be null).This will break the intended behavior of
skipError: true
To Reproduce
Expected behavior
When testProvider rebuilds, it'll keep showing the prev
data
while loading.but when AsyncError triggers, it'll lose the prev data and will show
error
instead.Expected behavior is to keep showing prev data as
skipError
is set totrue
The text was updated successfully, but these errors were encountered: