flutter icon indicating copy to clipboard operation
flutter copied to clipboard

flutter_image handling of exceptions from http clients not allowing retries.

Open tarobins opened this issue 6 years ago • 4 comments

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?

tarobins avatar May 24 '18 23:05 tarobins

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.

tarobins avatar May 29 '18 17:05 tarobins

cc @Hixie

zoechi avatar Jun 20 '18 08:06 zoechi

This is still happening - not necessarily only with timeouts (in my case, Connection closed before full header was received)

azack avatar Sep 14 '21 16:09 azack

Hello there This issue still exists and still happening. Any work around?

aziz-marashly avatar Jul 02 '23 11:07 aziz-marashly

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

jimmyff avatar Jan 31 '24 17:01 jimmyff