flutter
flutter copied to clipboard
flutter_image handling of exceptions from http clients not allowing retries.
In the flutter_image library, the FetchStrategyBuilder.build method returns a FetchStrategy that requires a non-null FetchFailure.httpStatusCode to return FetchInstructions.attempt any time after the first call to FetchStrategyBuilder.build. However, in NetworkImageWithRetry._loadWithRetry, when the http client throws an exception, a FetchFailure with a httpStatusCode of null is created, so no retry occurs on exceptions from the http client (in my case on a timeout). Is this the expected behaviour or should FetchFailure.httpStatusCode be 0 (to correspond with the Network Error code in defaultTransientHttpStatusCodes) when there's an exception thrown by the http client?
Another solution is that perhaps here we should also be checking for TimeoutException. I'm working on implementing this solution, but the testing is tricky so far.
cc @Hixie
This is still happening - not necessarily only with timeouts (in my case, Connection closed before full header was received
)
Hello there This issue still exists and still happening. Any work around?
I'm getting hundreds of these Crashlytics errors every day and would like to resolve this if possible.
I think the issue might have been fixed in Dart: https://github.com/dart-lang/sdk/commit/c286b76c2db394b72bd8ae79b32d024c2d25c52b
And NetworkImageWithRetry
needs allowLegacyUnsafeRenegotiation
set to true
in it's SecurityContext
. There is a disclaimer in the implementation comments:
/// NOTE: Renegotiation is an extremely problematic protocol feature and
/// should only be used to communicate with legacy servers in environments
/// where it is known to be safe.
Could this be added? If you know how you want it implementing (passing an optional allowLegacyUnsafeRenegotiation
bool or whole SecurityContext?) I'm happy to do it and send a PR