How to use the axios-retry.exponentialDelay function in axios-retry

To help you get started, we’ve selected a few axios-retry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kndt84 / aws-api-gateway-client / src / lib / apiGatewayCore / sigV4Client.js View on Github external
let signedRequest = {
      headers: headers,
      timeout: timeout,
      data: body
    };
    if (config.retries !== undefined) {
      signedRequest.baseURL = url;
      let client = axios.create(signedRequest);

      // Allow user configurable delay, or built-in exponential delay
      let retryDelay = function() {
 return 0;
};
      if (config.retryDelay === 'exponential') {
        retryDelay = axiosRetry.exponentialDelay;
      } else if (typeof config.retryDelay === 'number') {
        retryDelay = () => parseInt(config.retryDelay);
      } else if (typeof config.retryDelay === 'function') {
        retryDelay = config.retryDelay;
      }

      axiosRetry(client, {
        retries: config.retries,
        retryCondition: config.retryCondition,
        retryDelay,
      });
      return client.request({method: verb});
    }
    signedRequest.method = verb;
    signedRequest.url = url;
    return axios(signedRequest);
github kndt84 / aws-api-gateway-client / src / lib / apiGatewayCore / simpleHttpClient.js View on Github external
url += '?' + queryString;
    }

    let simpleHttpRequest = {
      headers: headers,
      timeout: timeout,
      data: body
    };
    if (config.retries !== undefined) {
      simpleHttpRequest.baseURL = url;
      let client = axios.create(simpleHttpRequest);

      // Allow user configurable delay, or built-in exponential delay
      let retryDelay = () => 0;
      if (config.retryDelay === 'exponential') {
        retryDelay = axiosRetry.exponentialDelay;
      } else if (typeof config.retryDelay === 'number') {
        retryDelay = () => parseInt(config.retryDelay);
      } else if (typeof config.retryDelay === 'function') {
        retryDelay = config.retryDelay;
      }

      axiosRetry(client, {
        retries: config.retries,
        retryCondition: config.retryCondition,
        retryDelay,
      });
      return client.request({method: verb});
    }
    simpleHttpRequest.method = verb;
    simpleHttpRequest.url = url;
    return axios(simpleHttpRequest);
github lifeomic / cli / lib / fhir.js View on Github external
// and will retry POST (normally POST requests are not
// retried since they are not idempotent, but in FHIR
// we use POST for searches and ingest, both of which are
// idempotent (assuming ingest uses client supplied ids
// which it usually does.), and will retry timeouts.
// This all makes ingest in particular much more reliable,
// which is important when ingesting large datasets.
const shouldRetry = error => {
  return axiosRetry.isNetworkError(error) ||
    axiosRetry.isRetryableError(error) ||
    error.code === 'ECONNABORTED' ||
    (error.response && error.response.status === 429);
};
const retryConfig = {
  retries: 5,
  retryDelay: axiosRetry.exponentialDelay,
  retryCondition: shouldRetry,
  shouldResetTimeout: true
};
axios.defaults.timeout = 16000; // 16 seconds

axios.defaults.headers.common['User-Agent'] = `${name}/${version}`;

function request (options) {
  const environment = config.getEnvironment();

  const account = options.account || config.get(`${environment}.defaults.account`);
  if (!account) {
    throw new Error(`Account needs to be set with 'lo defaults' or specified with the -a option.`);
  }

  const proxy = configureProxy.configureProxy();
github CloudBoost / cloudboost / sdk / src / PrivateMethods.js View on Github external
if (CB._isNode) {
        Axios = require('Axios');
    } else {
        Axios = require('axios');
    }

    if (!isServiceUrl) {
        var ssid = CB._getSessionId();
        if (ssid != null)
            headers.sessionID = ssid
    }

    if (params && typeof params != "object") {
        params = JSON.parse(params);
    }
    axiosRetry(Axios, { retryDelay: axiosRetry.exponentialDelay });
    Axios({
        method: method,
        url: url,
        data: params,
        headers: headers,
        onUploadProgress: function (event) {
            if (event.lengthComputable) {
                var percentComplete = event.loaded / event.total;
                if (progressCallback)
                    progressCallback(percentComplete)
            }
        }
    }).then(function (res) {
        if (!isServiceUrl) {
            var sessionID = res.headers.sessionid
            if (sessionID)
github segmentio / analytics-node / index.js View on Github external
this.host = removeSlash(options.host || 'https://api.segment.io')
    this.timeout = options.timeout || false
    this.flushAt = Math.max(options.flushAt, 1) || 20
    this.flushInterval = options.flushInterval || 10000
    this.flushed = false
    Object.defineProperty(this, 'enable', {
      configurable: false,
      writable: false,
      enumerable: true,
      value: typeof options.enable === 'boolean' ? options.enable : true
    })

    axiosRetry(axios, {
      retries: options.retryCount || 3,
      retryCondition: this._isErrorRetryable,
      retryDelay: axiosRetry.exponentialDelay
    })
  }
github envkey / envkey-app / envkey-react / src / lib / s3 / index.js View on Github external
import axios from 'axios'
import axiosRetry from 'axios-retry'
import R from 'ramda'

const client = axios.create({timeout: 3000})

axiosRetry(client, {
  retries: 5,
  retryDelay: axiosRetry.exponentialDelay,
  retryCondition: R.always(true),
  shouldResetTimeout: true
})

export const s3Client = client

axios-retry

Axios plugin that intercepts failed requests and retries them whenever posible.

Apache-2.0
Latest version published 4 months ago

Package Health Score

82 / 100
Full package analysis