-
Notifications
You must be signed in to change notification settings - Fork 1.7k
type error when specifiying a connectionTimeout for HttpClient #44895
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
Comments
cc @lrhn |
I believe the problem is the following: Future socketFuture = task.socket; // type of task.socket: Future<Socket>
// ...
// but socketFuture is used as a Future<Socket?>, if there is a timeout it returns null:
socketFuture = socketFuture.timeout(connectionTimeout, onTimeout: () {
_socketTasks.remove(task);
ask.cancel();
return null;
}); What's the proper way to convert a |
Currently there is no easy way to just introduce nullability in the type of a future. socketFuture = socketFuture.then<Socket?>((x) => x).timeout(....); We could perhaps introduce a
but we can't restrict it to up-casts, so it's going to be doing dynamic casts of all events, even when not necessary. I'll fix the |
This would have been caught if the static type had not been made `Future<dynamic>`. Fixes #44895 BUG= http://dartbug.com/44895 TEST= standalone/io/regress_44895 Change-Id: I237c552fdb42943b395352a7232b34ab5488ac6b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184261 Reviewed-by: Nate Bosch <[email protected]> Commit-Queue: Lasse R.H. Nielsen <[email protected]>
It is currently unclear when/how a null safe version of dio will be released because the mantainer is inactive, but this bug will likely block a release. Is it possible to uplift this fix (if that is necessary)? |
This issue was cherry picked in #44989, and is available in Dart's beta channel in version 2.12.0-259.14.beta and later. |
Uh oh!
There was an error while loading. Please reload this page.
Minimal code example:
results in:
OS: linux
dart:
Dart SDK version: 2.13.0-0.0.dev (dev) (Thu Feb 4 08:08:19 2021 -0800) on "linux_x64"
The text was updated successfully, but these errors were encountered: