-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download causes Timeout exception #2034
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
I don't understand how this is related to this problem. Do you mind explaining it to me? |
We are currently trying to fix a couple things but it does not seem to be related directly.
I was not aware of this and I have not seen any code which would support this. |
Could you provide a reproducible URL or example? |
Sure, void dummyDownload() async {
final tmpDir = await getTemporaryDirectory();
final File file = File('${tmpDir.path}/dummy.zip');
var dio = Dio(BaseOptions(
connectTimeout: Duration(seconds: 5),
receiveTimeout: Duration(seconds: 5),
));
// Some file that is rather "large" and takes longer to download
var uri = "https://github.com/cfug/flutter.cn/archive/refs/heads/main.zip";
var response = await dio.download(
uri,
file.path,
onReceiveProgress: (received, total) {
print('Received: $received, Total: $total');
},
);
print('Download is done: ${response.statusCode}');
} |
Thanks. I can easily reproduce the issue with your example. |
This is caused by a duplicate timeout handler in the dio/dio/lib/src/dio/dio_for_native.dart Lines 183 to 190 in 6e83a11
|
#2029 (comment) - Possibly fixes #1739 - Fixes #2034 ### New Pull Request Checklist - [x] I have read the [Documentation](https://pub.dev/documentation/dio/latest/) - [x] I have searched for a similar pull request in the [project](https://github.com/cfug/dio/pulls) and found none - [x] I have updated this branch with the latest `main` branch to avoid conflicts (via merge from master or rebase) - [x] I have added the required tests to prove the fix/feature I'm adding - [x] I have updated the documentation (if necessary) - [x] I have run the tests without failures - [x] I have updated the `CHANGELOG.md` in the corresponding package --------- Signed-off-by: Alex Li <[email protected]>
Package
dio
Version
5.3.3
Operating-System
Android
Output of
flutter doctor -v
Dart Version
3.1.3
Steps to Reproduce
Dio.download()
request with areceiveTimeout
set that will trigger (In my case the download takes 10s so I set it to 3s).Expected Result
As stated in the readme and the code itself, dio should only throw a
TimeoutException
based on thereceiveTimeout
defined "timeout during data transfer of each bytes and not the overall timing during the receiving.".Therefore, the download should finish without any issue since bytes are constantly received.
Actual Result
The download is stopped due to a
TimeoutException
of thereceiveTimeout
. However, using theonReceiveProgress
callback of the download method, I can see that progress and therefore bytes are received constantly.The text was updated successfully, but these errors were encountered: