-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DioError [DioErrorType.response]: Http status error [307] #0 DioMixin.assureDioError (package:dio/src/dio_mixin.dart:819:20) #1306
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
307 is not regard as success,so throw error is expected..... I can't get what your problem is. |
I got here looking for the same answer but with 404 response status code. I think the problem is that it is not clear how to handle response errors in the new version of Dio. Previous versions worked with try-catch but this new version throws errors before they get to where we called a Dio request method. I believe the solution is to implement an interceptor with a handler in onError method and handle or pass the response as is to be caught with custom try-catch logic; as seen here https://github.com/flutterchina/dio/blob/16c6da8514008a012f713c14275d04aab28e6bf7/example/response_interceptor.dart can you maybe update the readme with how to properly handle or catch Dio errors in the new version? |
@wendux
if you have any better way to handle this, please share |
This seems related to #1171 @markfili Could your elaborate more? I tried to use the interceptor you provided but still having the same exception thrown even though the call is sounded with try/catch
|
@a7md0 good job on finding all those related issues, I'm impressed! I think that, at the moment, maintainers don't really understand what our problem is and I believe we're experiencing something that has to do with how my problems were seemingly solved by adding that interceptor which allowed the DioError to propagate to the try-catch block where I expected it to arrive; logs still show it throws the I'm open to help and investigate further. |
@markfili Thanks for following up. I have tried to supply catchError on the call, but still the unhandled exception is not caught directly. Here is the order while debugging:
|
hmm, I'm not sure how to say this but... it suddenly started working as intended... I was trying to test out older versions of Dio and http_parser and when I reverted to latest versions, there was no more assureDioError exception in the logs and the try/catch caught the error... I guess there was some cache leftovers? I'm not sure how to explain what happened... I've used your example to create this test app: https://github.com/markfili/dio_tester first try to get the error by launching a few requests with and without catchError.
this is how the External Libraries - Dart packages looks now in my projects: |
@markfili Using the repo you provided, as soon as I launched the application I received the same exception Here is what my breakpoints look like I am actually using the same dio 4.0.1 version, here is my minimal repo. Would you mind sharing your Visual Studio Code version:
|
I could confirm that I have the same versions as you described. And yes I receive the same output when it get caught in the catch block. But before that occurs, the debugger steps in and pause the execution as following (Only after I click the continue button (F5) my catch block get executed) This might be related to VSCode then, I will try that on Android Studio and post the result. Which also would explain why you were having this issue, but it might been resolved by Android Studio updates |
Ah, this is then another type of issue I was not aware of. I was focused on solving the "unable to catch DioError in try/catch" issue when just running the app using the play button (not in IDE's debug mode - without attaching the debugger). The issue there was that the exception was thrown in the logs but never arrived to the catch block, correct? If you can catch DioError in the catch block but it stops execution when using a debugger then that might be something related to the IDE and debugger settings. It can probably be evaded by unchecking the "Break on exceptions" in Debugger settings but it might not be the best thing to do as it will do that to all exceptions. Sure, try and report back so we can reassess the situation and define a new problem if necessary. |
No the issue was that I could not prevent DioError from being thrown, even with the try/catch around the call. It did arrive to the catch block, but only after clicking
I agree, this might be related to the IDE debugger. But why it is only triggered with this package?
True, unchecking the
I've just tried |
I'm not sure, I'm investigating, but... |
flutter/flutter#33427 (comment) This might be an approximate explanation of what's going on |
@a7md0 can you please pull my project again and try to reproduce the debugger issue? https://github.com/markfili/dio_tester edit from tomorrow: I've updated the above project repository with latest Dio 4.0.3 |
try with 4.0.2 |
working! |
Looks like this was fixed in 4.0.2 |
This issue is back in 4.0.6 |
Issue is back. |
back again. |
back again in 4.0.6 |
Back again in 4.0.6, any news about this ? I use QueuedInterceptorsWrapper |
Does anyone have a(ny) test(s) that could repeatedly confirm this issue? |
I have this problem but
|
this appears to be back with a new Flutter release 3.16.0. Is anyone experiencing the same issue? |
@shkvoretz Yes. I've been looking for a solution for a few days now. Still no luck. |
Add interceptor rule in Dio dio.interceptors.add(InterceptorsWrapper(onError: (DioError e, handler) {
|
Uh oh!
There was an error while loading. Please reload this page.
New Issue Checklist
dio does not read the response of a rest call, below I leave an example of the json returning from
Issue Info
Platform Name iPhone 12 Pro Max
Platform Version iOS 15
Dio Version 4.0.0.
Xcode version 10.2.1
Repro rate all the time (100%)
Issue Description and Steps
Code:
JSON return:
The text was updated successfully, but these errors were encountered: