Conversation
|
@martijn00 can we have this reviewed? Thans for the time effort :D |
|
|
|
Thanks @rickdijk — merged One thing to flag before release: |
|
Follow-up draft PR for It depends on this PR (flutter_cache_manager 3.5.0), so its CI stays red until 3.5.0 is published. |
rickdijk
left a comment
There was a problem hiding this comment.
Few comments on this PR:
-
Queued requests run with the wrong timeout. When more than 10 downloads are running, a new request waits in a queue. The queue doesn't store its timeout, so it later runs with the timeout of whichever download just finished.
-
This is a breaking change shipped as a minor version. Adding
timeoutto the abstractFileService.getbreaks every class that overrides it. That includes this repo's ownFirebaseHttpFileService, which accepts^3.4.2and so would pick up3.5.0and fail to compile. -
The timeout only covers the wait for response headers, so a stalled body download still hangs.
-
A timed-out request is never cancelled, so its connection stays open.
-
A caller that joins a download already in progress has its timeout ignored.
-
getSingleFiledoesn't accept a timeout at all. -
There are no tests for the new behavior
I'm pretty convinced it would be simpler fix to set a timeout once on HttpFileService instead of passed through five layers. That won't break anything and avoids the problems mentioned above.
Let me know what your thoughts are :)
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
This PR is to resolve #141, supporting pass
timeoutfor downloading.There is no way to set
timeout.🆕 What is the new behavior (if this is a feature change)?
A
timeoutduration can be set, and the http request will be timeouted after the duration (aTimeoutExceptionwill be thrown). Iftimeoutis not set, all behaviors are same with the original.💥 Does this PR introduce a breaking change?
N/A for
flutter_cache_manager(see follow-up note below forflutter_cache_manager_firebase).🐛 Recommendations for testing
TimeoutExceptionafter the duration.timeoutis not set.📝 Links to relevant issues/docs
Issue #141.
🤔 Checklist before submitting
flutter_cache_manager_firebase(separate package)This change adds
Duration? timeouttoFileService.get.flutter_cache_manager_firebaseoverrides that method inFirebaseHttpFileServicewithouttimeout, so once this is released as3.5.0(its constraintflutter_cache_manager: ^3.4.2allows3.5.0) that override becomes aninvalid_overridecompile error. A follow-up PR will addtimeoutthere and forwardheaders/timeouttosuper.get. Please hold thev3.5.0tag until that follow-up lands. This PR only touchesflutter_cache_manager.