dart-neats
dart-neats copied to clipboard
Doesn't work with Riverpod
i implemented riverpod
package on our application and after install and using this library and I get this error:
TimeoutException after 0:00:03.000000: Future not completed
And retry
doesn't attempt again to send request
class LoginRepository {
final Reader _reader;
LoginRepository(this._reader);
Future<LoginResponseStructure> getLoginResponse(String mobileNumber) async {
try {
const r = RetryOptions(maxAttempts: 3);
final response = await r.retry(
() => _reader(dioProvider)
.post(
Server.$signUP,
queryParameters: {'mobile_number': mobileNumber},
options: Options(
headers: {'Content-Type': 'application/json'},
),
)
.timeout(const Duration(seconds: 30)),
retryIf: (e) => e is SocketException || e is TimeoutException,
);
return LoginResponseStructure.fromJson(response.data as Map<String, dynamic>);
} on DioError catch (e) {
throw e.error as Object;
}
}
}
Are you sure it's not a different timeout?
@jonasfj yes
Can you make a self-contained example.. maybe do .timeout(const Duration(seconds: 30))
and see if you can reproduce reliably, and insert some print
statements in retryIf
to see what it called with.
My two cents is that it's failing with another exception, or that something you've imported defines a TimeoutException
different from the one in dart:async
.
Or that retry
is broken is some other way, that is independent on riverpod
and can be reproduced by just trying to handle timeouts in general.
If anyone can demonstrate a trivial example and find a bug in retry I down for fixing it. But realistically I doubt much progress will be made on this issue.
Its entirely likely that it's a different timeout in a microtask, or that all retries are exhausted.