Code Monkey home page Code Monkey logo

dio_retry's People

Contributors

aloisdeniel avatar amreniouinnovent avatar azimuthdeveloper avatar

Stargazers

 avatar  avatar

dio_retry's Issues

Empty errorCallback throw exception

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()));

Thx.
img

I am getting build time error when using the plugin.

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;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.