dio icon indicating copy to clipboard operation
dio copied to clipboard

DioError [DioErrorType.other]: Invalid argument(s) (onError): The error handler of Future.catchError must return a value of the future's type

Open JanKokalj opened this issue 2 years ago • 0 comments

New Issue Checklist

  • [x] I have searched for a similar issue in the project and found none

Issue Info

Info Value
Platform Name Android
Platform Version 10.0
Dio Version 4.0.4
Android Studio / Xcode Version IntelliJ 2021.3.2
Repro rate Hard to reproduce

Issue Description and Steps

This is hard to reproduce. It happens when our app is in the foreground and you lock the screen of the device, then after about half an hour later, you unlock the device (we fetch new data), and then this exception happens (the same request and all other requests are working in other scenarios/times). I could not find anything related to this on the internet so I am opening an issue here to get some more insights. The stack traces are:

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: DioError [DioErrorType.other]: Invalid argument(s) (onError): The error handler of Future.catchError must return a value of the future's type
#0      _FutureListener.handleError (dart:async/future_impl.dart:194)
#1      Future._propagateToListeners.handleError (dart:async/future_impl.dart:779)
#2      Future._propagateToListeners (dart:async/future_impl.dart:800)
#3      Future._completeError (dart:async/future_impl.dart:610)
#4      Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:666)
#5      _rootRun (dart:async/zone.dart:1428)
#6      _CustomZone.run (dart:async/zone.dart:1328)
#7      _CustomZone.runGuarded (dart:async/zone.dart:1236)
#8      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276)
#9      _microtaskLoop (dart:async/schedule_microtask.dart:40)
#10     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49)

Source stack:
#0      DioMixin.fetch (package:dio/src/dio_mixin.dart:473)
#1      DioMixin.request (package:dio/src/dio_mixin.dart:468)
#2      DioMixin.get (package:dio/src/dio_mixin.dart:55)
#3      AuthenticatedHttpClientImpl.get.<anonymous closure> (package:/../layers/network/http_client/authenticated_http_client_impl.dart:93)

Relevant code:

late Dio _dioClient;

_dioClient = Dio();

_dioClient.get(
        uri.toString(),
        options: Options(
          extra: _createExtraMap(requiresAuthToken),
          responseType: ResponseType.plain,
          headers: headers,
        ),
      )

JanKokalj avatar Feb 21 '22 13:02 JanKokalj