Retry interceptor for dio.
azimuthdeveloper / dio_retry Goto Github PK
View Code? Open in Web Editor NEWThis project forked from aloisdeniel/dio_retry
Retry interceptor for dio.
License: MIT License
This project forked from aloisdeniel/dio_retry
Retry interceptor for dio.
License: MIT License
Make it so retries can take steadily more and more time, not just a pre-set time.
Hi!
I am install dio_retry_fixed, but when interceptor trying to re-send request, package throw exception.
I'll debug the code a little bit and found unknown function Function(ErrorResult err) errorCallback
in code of pub.dev package (https://storage.googleapis.com/pub-packages/packages/dio_retry_fixed-0.1.11-beta.tar.gz)
If I correct understand, this function should be replace logger?
Can you add some extra check?
For example:
if (errorCallback != null)
errorCallback(ErrorResult(err.request.uri.toString(), err.message,
extra.retries, err.error.toString()));
dio 4.0.0
dio_retry_fixed: ^0.1.15-beta-null-safety
The issue is inside plugin files here is the error log.
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:30:32: Error: The getter 'request' isn't defined for the class 'DioError'.
- 'DioError' is from 'package:dio/src/dio_error.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/dio_error.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'request'.
err.request!.extra = err.request!.extra..addAll(extra.toExtra());
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:33:40: Error: The getter 'request' isn't defined for the class 'DioError'.
- 'DioError' is from 'package:dio/src/dio_error.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/dio_error.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'request'.
errorCallback!(ErrorResult(err.request!.uri.toString(), err.message, extra.retries, err.error.toString()));
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:39:15: Error: The getter 'request' isn't defined for the class 'DioError'.
- 'DioError' is from 'package:dio/src/dio_error.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/dio_error.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'request'.
err.request!.path,
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:40:28: Error: The getter 'request' isn't defined for the class 'DioError'.
- 'DioError' is from 'package:dio/src/dio_error.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/dio_error.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'request'.
cancelToken: err.request!.cancelToken,
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:41:21: Error: The getter 'request' isn't defined for the class 'DioError'.
- 'DioError' is from 'package:dio/src/dio_error.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/dio_error.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'request'.
data: err.request!.data,
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:42:34: Error: The getter 'request' isn't defined for the class 'DioError'.
- 'DioError' is from 'package:dio/src/dio_error.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/dio_error.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'request'.
onReceiveProgress: err.request!.onReceiveProgress,
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:43:31: Error: The getter 'request' isn't defined for the class 'DioError'.
- 'DioError' is from 'package:dio/src/dio_error.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/dio_error.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'request'.
onSendProgress: err.request!.onSendProgress,
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:44:32: Error: The getter 'request' isn't defined for the class 'DioError'.
- 'DioError' is from 'package:dio/src/dio_error.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/dio_error.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'request'.
queryParameters: err.request!.queryParameters,
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:45:39: Error: The getter 'request' isn't defined for the class 'DioError'.
- 'DioError' is from 'package:dio/src/dio_error.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/dio_error.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'request'.
options: Options(extra: err.request!.extra),
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:38:16: Error: A value of type 'Response' can't be returned from an async function with return type 'void'.
- 'Response' is from 'package:dio/src/response.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0/lib/src/response.dart').
return await dio.request(
^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:48:16: Error: A value of type 'Object' can't be returned from an async function with return type 'void'.
- 'Object' is from 'dart:core'.
return e;
^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:52:25: Error: Too few positional arguments: 2 required, 1 given.
return super.onError(err);
^
../../.pub-cache/hosted/pub.dartlang.org/dio_retry_fixed-0.1.15-beta-null-safety/lib/src/retry_interceptor.dart:52:18: Error: A value of type 'invalid-type' can't be returned from an async function with return type 'void'.
return super.onError(err);
^
Command PhaseScriptExecution failed with a nonzero exit code
FirebasePerformance-gmrrcesyyvkfjbflfjwkdefehdqi
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.
Exited (sigterm)
This is my code and there is no issue.
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:dio_retry_fixed/dio_retry_fixed.dart';
// import 'package:dio_firebase_performance/dio_firebase_performance.dart';
// import 'package:dio_retry/dio_retry.dart';
import 'theme_action.dart';
import 'package:path/path.dart' as path;
int _apiCounter = 0;
Dio _dioObj;
Dio get _dio {
if (_dioObj == null) {
_dioObj ??= new Dio();
_dioObj
..interceptors.add(RetryInterceptor(
dio: _dioObj,
// logger: Logger("Retry"),
options: RetryOptions(
retries: 3, // Number of retries before a failure
retryInterval: const Duration(seconds: 3),
retryEvaluator: (error) =>
error.type != DioErrorType.cancel &&
error.type != DioErrorType.response),
));
// _dioObj.interceptors.add(DioFirebasePerformanceInterceptor());
}
return _dioObj;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.