-
-
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
Interceptor onError handling broken #2167
Comments
The cause is #2139 In your example you can just remove the |
Generally we should avoid We can figure out what we can do here for better experiences. |
It actually breaks all interceptors written in |
Reverts #2139 Fixes #2167 Reopen #2138 ### 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) - [ ] 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 ### Additional context and info (if any) Added tests were fake, so they remained effective after the revert.
Package
dio
Version
5.4.2
Operating-System
Android
Adapter
Default Dio
Output of
flutter doctor -v
Dart Version
3.3.2
Steps to Reproduce
The onError handler of a new class that extends the "Interceptor" class will not allow subsequent interceptors to successfully catch exceptions.
Please consider the following example which is derived from this example:
Expected Result
I/flutter (xx): onError
I/flutter (xx): CAUGHT error: DioException [receive timeout]: The request took longer than 0:00:02.000000 to receive data. It was aborted. To get rid of this exception, try raising the RequestOptions.receiveTimeout above the duration of 0:00:02.000000 or improve the response time of the server.
I/flutter (xx): 500
Actual Result
The debugger halts the execution after the "onError" output. Forcing the debugger to continue yields the following error:
This means the onError handler of the second interceptor is acutally executed, but it is not able not catch the exception properly.
If we now replace
with
everything works as expected.
Using inline InterceptorsWrapper instead of a custom class also prevents this problem from appearing.
I guess that there is a simple explanation for this behavior, but I could not find it in the docs.
For example the dio_cache_interceptor package is implemented by extending the "Interceptor" class which triggers the described behavior that breaks my project.
The text was updated successfully, but these errors were encountered: