-
Notifications
You must be signed in to change notification settings - Fork 351
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
type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic' #418
Comments
Thank you for the detailed report! Your analysis is spot on. |
Note that this doesn't in itself cause a problem to happen, what it does is mask the real problem and potentially thwart workarounds that would otherwise catch the I think the fix here is easy, it's a bit tougher to test. What I need is to be able to come up with a way to guarantee that the |
I'm not entirely sure I understand the problem. I guess what you mean is I think current implementation does make sure only |
What I'm hoping for is some situation that I can hopefully set up with a server (in Dart) such that there would be an error on that Stream. Something like, perhaps, closing the stream early on the server side? If it's not easy to write up a server in Dart that would cause an error on the response stream in a Dart client I can instead try the mocking approach. |
With the current setup, all One way to do it is |
I have this error when I put have a response very larger. I need to pass 10 images from server to my app. If I don't put then in response, the request works. Else, I see this error message. |
@LeandroMoura3 This is suspicious. I don't think a large payload will lead to an error. @natebosch I think the original problem should be fixed. What I mean is we need a better way to surface the underlying exception. With the current setup, all invalid exceptions will trigger this subtype error. But what users want is the real root cause. It should be changed to be more informative. Is it a good idea to optional adding a type to |
@zichangg I think that you can reproduce that error very easy. In my case, works in the follow way: I have a db with registers of establishments. When I request this this querys with the base64 images, the error happens. When I request this querys without base64 images, then works fine. You can convert a image to base64 image in the internet, is a big string. I convert it to a image with base64decode. I make this strategy because I wanna a faster developer for begin, but I think that not is the more performatic way to deal with images in web. Edit: when I send a json array with 10 itens, don't works. When I send only 1 item, this works. Here is the error when fails:
|
Fixes #418 The argument type for `handleError` is `Function` to allow callbacks that do or don't take the `StackTrace` argument, so we don't get static checking. In either case the first argument is expected to allow `dynamic`. TODO: Add a test
This will be fixed by #429 - blocked by validation with a test. |
This is probably a duplicate with flutter/flutter#58676 |
@LeandroMoura3 do you know how large your json is? Our buffer size limit is 8K. I'm not super familiar with our secure socket implementation. But I guess your json exceeds the size limit. |
There is 149889 bytes. This pass a lot of 8K, right? But sometimes works, sometime don't work. I put a looping for when the error ocorres, try again, until all images are loaded. There implies in more call to the server. I use a local server. I think that the fast speed of answer and big content are the key for this bug. I have a little hope that when I use a remote server, this bug don't happens. PS: with one image have this size. Ten images are approximately ten times this. |
@LeandroMoura3 I'm spending time to understand that part of code. Are you able to get a sample program to repro? |
I think the reason is because, ssl operations in This exception is thrown by http parser, which utilizes some internal states to find the http response has not fully received but onDone callback has fired. I can't verify without a sample program. I've seen openssl having a "ssl_has_pending()" to check whether there is unprocessed data. This will be helpful. We can add a check to close the stream until all incoming data has been processed. But looks like boringssl we are using doesn't have this API yet. |
Hello @zichangg As I talk latter, it's a very simples bug to reproduce, in my opinion. But I will put here a example of a code that I use to connect to my API server. Here is:
Here is the log: The server is local flask with mongoengine. |
Here is the base64 response for example:
|
I put this call in a looping for a workaround.
In my server, for ten imagens, a make 15~20 requests, and it works. All teen images are loaded. Anyway, this bug happens with a minor frequency in shorts call too, like Login Call API. The structure of call is the same that showed. But, again, it is in local server. |
I appreciate the TDD stance on this; however, we’re approaching two months for a simple one-line fix of a fairly serious bug that’s been there for eight months. How about just reverting afcbd57 (which did not come with tests), and then reintroducing that commit along with a fix and a test that proves the bug is not there? |
Fixes #418 The argument type for `handleError` is `Function` to allow callbacks that do or don't take the `StackTrace` argument, so we don't get static checking. In either case the first argument is expected to allow `dynamic`. TODO: Add a test
We occasionally see an error with the message "type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic'" with the top of the stack
I think it's caused by https://github.com/dart-lang/http/blob/master/lib/src/io_client.dart#L49, which passes an error handler of wrong type.
The fact that the function handler is wrong can be seen by running
Changing it to
resolves the issue.
Possibly related: flutter/flutter#50042.
The text was updated successfully, but these errors were encountered: