Forever retry on second invalidate of provider, using asReload (riverpod version: 3.0.3)
Describe the bug Provider will be stuck in "loading state" second time invalidated (with asReload flag true).
The retry logic is totally ignored when not using the asReload flag after myRetry() returned null.
(That seems correct since it is holding it last good state... Also found out I can see a loading state using the skipLoadingOnRefresh: false flag in .when(). But though, it should not be stuck when using asReload :) )
(Disclaimer: I am currently learning Riverpod and cannot figure out why this is happening)
To Reproduce Created this provider:
final testProvider = FutureProvider.family<List<String>, bool>((ref, forceReload) async {
final random = Random();
int itemCount = random.nextInt(100);
await Future.delayed(Duration(seconds: 2));
if(itemCount >= 5) {
throw Exception("We are throwing an error");
}
return List.generate(itemCount, (index) => "item $index");
});
Refresh are triggered like this: ref.invalidate(testProvider, asReload: true);
Log would something like this:
Syncing files to device macOS... flutter: Retry count: 0 flutter: Retry count: 1 flutter: Retry count: 2 flutter: Retry count: 0 flutter: Retry count: 0 flutter: Retry count: 0 flutter: Retry count: 0 flutter: Retry count: 0
Created an example project to quick check, tested on macOS: https://github.com/large/riverpodretry
Expected behavior When using the "asReload" flag I would expect the retry logic to trigger again and not be stuck in forever retry.
Is this a bug or totally wrong use of the provider?