Code Monkey home page Code Monkey logo

retry-axios's People

Contributors

aaronrprince avatar andyogo avatar aro1976 avatar arunredhu avatar barrett-schonefeld avatar bdcarr avatar blakeyp avatar findmory avatar greenkeeper[bot] avatar jasminen avatar jgehrcke avatar jpoehnelt avatar justinbeckwith avatar noahhoffman avatar npbenjohnson avatar orgads avatar renovate[bot] avatar richardharrington avatar softwareandoutsourcing avatar wuzi avatar yoshigev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

retry-axios's Issues

Potential errors when computing exponential backoff and linear backoff

The code to compute the linear backoff and exponential backoff has some issues, as it does not wait in the first attempt, this is because currentRetryAttempt is initially set to 0 instead of 1. See

retry-axios/src/index.ts

Lines 183 to 188 in c284310

if (config.backoffType === 'linear') {
delay = config.currentRetryAttempt! * 1000;
} else if (config.backoffType === 'static') {
delay = config.retryDelay!;
} else {
delay = ((Math.pow(2, config.currentRetryAttempt!) - 1) / 2) * 1000;
.

It also does not consider the retryDelay, which according to the readme:

Milliseconds to delay at first. Defaults to 100.

Additionally, the formula for computing the exponential backoff should be something like:

Math.min((Math.pow(2, config.currentRetryAttempt) + Math.random()), MAX_DELAY) * 1000

See https://cloud.google.com/iot/docs/how-tos/exponential-backoff#example_algorithm

That would give retry times like:

1.234
2.314
4.012

Compare that to the times obtained with the current algorithm:

0
0.5
1.5

Unable to override raxConfig using axios 0.19.0 and retry-axios 2.1.1

I created the following gist to demonstrate the inability to override the config beyond the defaults. Executing this script fails on first attempt and no retry is executed. Using default settings, as shown in method 1, I've seen the 3 retry attempts in the config but this gist does not have that working. Execution methods are in comments at the bottom of the file.

https://gist.github.com/mkiddTempus/4ce156382c1b654b34d44d1900a37d2b

Custom HttpsAgent gets corrupted after retry

Using a custom HttpsAgent to make requests over proxy. Whenever a request fails, rax tries to retry the request but following error occurs.

The "options.agent" property must be one of type Agent-like Object, undefined, or false. Received type object
TypeError [ERR_INVALID_ARG_TYPE]: The "options.agent" property must be one of type Agent-like Object, undefined, or false. Received type object
at new ClientRequest (_http_client.js:112:11)
at Object.request (https.js:303:10)
at dispatchHttpRequest (/xxx/node_modules/axios/lib/adapters/http.js:141:25)
at new Promise ()
at httpAdapter (/xxx/node_modules/axios/lib/adapters/http.js:18:10)
at dispatchRequest (/xxx/node_modules/axios/lib/core/dispatchRequest.js:59:10)

Before the "retry" trials, custom agent and all the requests works.

'shouldRetry' and 'retry' together are not working fine.

Independently both "shouldRetry"and "retry" work fine.
When put together, "retry" loses it significance.

`
raxConfig: {

    retry: 5,

    shouldRetry: (err) => {
          if(condition)  return true;
          else return false;
    },

    onRetryAttempt: (err) => {
      return true;
    },
  },

`

For the above raxConfig, it doesn't stop after 5 retries. It retries infinitely.

Double base url appended

Using /v1/api via:

window.axios.defaults.baseURL = '/v1/api/'

On error results in
'/v1/api/v1/api' call

is project still maintained?

Hi @JustinBeckwith I wanted to check if this project is still maintained and whether you would be willing to accept contributions.

I see that there are a couple of duplicated issues, dating a long back, and also there are some new issues reported.

onRetryAttempt doesn't handle promise rejection

So, following the example for an async onRetryError, I decide to not retry is errno === "ENOTFOUND" (kinda no point, right?)

So, I call my reject function. But I always get an UnhandledPromisRejectionWarning on those.

So it looks like there is no catch block for those?

Retries issues

By default , retry count is set to 3. But It's only trying two times. Doesn't have any effect if I define it to be 3, 4 or 5. It only tries 2 times. Please fix this issue. Thanks

[question] Is it possible to use this library via CDN?

I want to use this library in client-side (browser) JS but from a hosted platform where I can't store my own files. I'm loading axios from Cloudflare CDN using LazyLoad and it works fine, but I tried also loading retry-axios that way and got an immediate error as it was referring to axios by pathname. Is it possible to do what I'm trying to do?

Cannot set property 'raxConfig' of undefined

The line below in the function onError sometimes throws error "Cannot set property 'raxConfig' of undefined"

It happened when an axios call encountered a 401 error.

// Put the config back into the err
    err.config.raxConfig = config;

Looks like the err.config could be undefined.

Doesn't seem to work with IMPORT rax

Does NOT work

import axios from 'axios';
import rax from 'retry-axios';
console.log('TEST', rax);   // TEST undefined

WORKS

import axios from 'axios';
const rax = require('retry-axios');
console.log('TEST', rax);   // TEST { attach: [Function: attach], detach: [Function: detach], getConfig: [Function: getConfig] }

Is something up with the way this was packaged that would prevent it from being imported when working with webpack+babel?

Transpile to ES5

I want to use this package but it contains non-es5 keywords (const) in the output file.

Does not retry on timeout

I'm using retry-axios succesfully to retry on server-side errors like 5xx responses.
However, I'm also experiencing sporadically timeouts on the server-side. In this cases, there is no retry attempt.

I would consider timeouts a service-side error as well. Shouldn't there be a retry attempt?

docs/syntax not working as shown? and/or not catching ECONNREFUSED?

This is likely just my own mis-understanding of Node.js, but based on the docs I would assume this should work:

const rax = require('retry-axios');
const {axios} = require('axios');
async function main() {
  const interceptorId = rax.attach();
  const res = await axios('https://localhost');
}
main()

But instead it reports:

(node:50585) UnhandledPromiseRejectionWarning: TypeError: axios is not a function

I also tried:

const rax = require('retry-axios');
const Axios = require('axios')

const axios = Axios.create()
axios.defaults = {
  raxConfig: {
    onRetryAttempt: (err) => {
      const rcfg = rax.getConfig(err)
      console.log(`Retry attempt #${cfg.currentRetryAttempt}`)
    }
  }
}
const interceptorId = rax.attach(axios)

async function main() {
  res = await axios.get('https://localhost')
}

main()

I am hoping to have it catch connection refused (no server responding) and wait to retry... but it just errors out. My guess is I'm still missing somewhat on getting the syntax lined up.

This is on node.js v10.4.1, with no babel.

Thanks!

Cannot read property 'attach' of undefined

Hello

Im trying to use this library but i get the following error in my catch block

Cannot read property 'attach' of undefined

import axios from "axios";
import rax from "retry-axios";

try {

     const interceptorId = rax.attach();
     const metrics = await axios(this.getMetrics(session._id, sessionRequest._id));
} catch(err) {
    console.log(err);
}

public getMetrics(sessionId: any, requestId: any) {

        const url = this.config.backendUrl + "/check/metrics";

        const options = {
            url,
            method: "get",
            headers: {
                "X-IDCHECK-SESSION-ID": sessionId,
            },
            data: {},
            raxConfig: {
                // Retry 3 times on requests that return a response (500, etc) before giving up.  Defaults to 3.
                retry: 3,

                // Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc).
                noResponseRetries: 2,

                // Milliseconds to delay at first.  Defaults to 100.
                retryDelay: 100,

                // HTTP methods to automatically retry.  Defaults to:
                // ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
                httpMethodsToRetry: ["GET", "HEAD", "OPTIONS", "DELETE", "PUT"],

                // The response status codes to retry.  Supports a double
                // array with a list of ranges.  Defaults to:
                // [[100, 199], [429, 429], [500, 599]]
                statusCodesToRetry: [[100, 199], [429, 429], [500, 599]],

                // If you are using a non static instance of Axios you need
                // to pass that instance here (const ax = axios.create())
                // instance: ax,

                // You can detect when a retry is happening, and figure out how many
                // retry attempts have been made
                onRetryAttempt: (err) => {
                  const cfg = rax.getConfig(err);
                  console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
                },
              },
        };

        return options;

    }

Multiple request retry

My English is not good, sorry, please be patient and finish reading! It seems that retry-axios can only retry one request, but there are multiple real-time requests on the webpage, which cannot meet the needs of the project! Is there a setting or other scheme that can handle multiple requests and retry?

Set config instance when calling attach

The raxConfig requires an instance field, which if not set will default to the default axios instance, however that's not what one wants when attaching it to a non-default instance.

This is awkward an error prone, as one would need to create the object as follows:

const axiosInstance = axios.create({
  raxConfig: {
    retryDelay: 10000,
    backoffType: 'static',
  },
});
axiosInstance.defaults.raxConfig = {...axiosInstance.defaults.raxConfig, instance: axiosInstance};

Instead, I suggest to modify attach to do something like:

export function attach(instance?: AxiosInstance) {
  if (instance) {
    instance.defaults.raxConfig = {...instance.defaults.raxConfig, instance};
  }
  instance = instance || axios;
  return instance.interceptors.response.use(onFulfilled, onError);
}

statusCodesToRetry doesn't work when Http Status Code is 2xx

When specify statusCodesToRetry as 2xx, this doesn't work because of the following code:

export function attach(instance?: AxiosInstance) {
  instance = instance || axios;
  return instance.interceptors.response.use(onFulfilled, onError);
}

onError will be only triggered when the Http Status Code is not 2xx. That means all retries this library will perform only works when Http Status Code is not 2xx.

Won't retry more than once

EDIT: I swapped retry-axios for axios-retry @ https://github.com/softonic/axios-retry , using the same logical flow and it works fine with proper repeats. What's so different about retry-axios' implementation?

Hello.

I've been trying to get this wonderful interceptor all day but I just can't get it to work with my React app.

I have the following code.

export default{
  get(url, conf = {}) {
    const client = getClient();
    client.defaults.raxConfig = {
      retry: 5,
      instance: client,
      noResponseRetries: 5,
      statusCodesToRetry: [[100, 199], [400, 429],[500, 599]],
      onRetryAttempt: (err) => {
        const cfg = rax.getConfig(err);
        console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
      }
    }
    const interceptorId = rax.attach(client)
    return client.get(url, conf)
  }
}

Basically another apiCall.js file calls the exported function, it creates an axios instance with some basic options via getClient(), attaches the raxConfig, attaches rax itself and then returns the get request.

The apiCall.js file then resolves the promises via .then() and .catch().

The problem im experiencing is no matter what I do retry-axios only retries once.

I know it uses the config because it properly reacts to changes in statusCodesToRetry, but doesn't do anything after the first retry.

I'm really desperate here and any help is appreciated. Thank you.

Update README docs to prevent overriding Axio's defaults

Hi all, I'm rather new to using axios and needed a way to perform some retries when requests failed. I was going through the README docs and got up and running real quick, but then I hit a brick wall, and found retry-axios not working what so ever. After figuring out my mistake I wanted to point out where I "went wrong", either to help others who ran into similar issues, or to possibly improve the docs to prevent my mistakes from happening to others.

Currently the README has this snippet:

const myAxiosInstance = axios.create();
myAxiosInstance.defaults = {
  raxConfig: {
    instance: myAxiosInstance
  }
}
const interceptorId = rax.attach(myAxiosInstance);
const res = await myAxiosInstance.get('https://test.local');

Which I used for my own setup, and found rax wasn't working, where the onRetryAttempt method wasn't being called. After struggling with all the retry-config settings I eventually changed my code to look this like:

const myRaxConfig = {/*my settings*/};
const myAxiosInstance = axios.create();
myAxiosInstance.defaults.raxConfig = myRaxConfig;
const interceptorId = rax.attach(myAxiosInstance);
const res = await myAxiosInstance.get('https://test.local');

After-which retry-axios started working, and started calling the onRetryAttempt callback.
It seems when doing this:

myAxiosInstance.defaults = {
  raxConfig: {
    /*my rax config settings*/
  }
}

You take the following (rough) default axios configs:

{
  "transformRequest": [
    null
  ],
  "transformResponse": [
    null
  ],
  "timeout": 0,
  "xsrfCookieName": "XSRF-TOKEN",
  "xsrfHeaderName": "X-XSRF-TOKEN",
  "maxContentLength": -1,
  "headers": {
    "common": {
      "Accept": "application/json, text/plain, */*"
    },
    "delete": {},
    "get": {},
    "head": {},
    "post": {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    "put": {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    "patch": {
      "Content-Type": "application/x-www-form-urlencoded"
    }
}

and set it to just the rax config. (as seen in the code-snippet at the top)


So I think we should update this snippet in the README to prevent any issues where developers use the code snippet without realizing they are effectively removing a bunch of default settings for axios.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

IE throws SCRIPT1002: Syntax error

First, really neat interceptor with a great API.

IS:

IE11 throws:

SCRIPT1002: Syntax error

All arrow functions aren't transpiled, see:
https://unpkg.com/[email protected]/build/src/index.js

retry-axios-ie-syntaxt-error

EXPECTED:

I expect to import an ES Module and bundle it with Webpack/Rollup/Parcel without the need to transpile retry-axios itself by Babel.

I'm talking about the provided main and missing module field as definied by the spec below:

"main": "./build/src/index.js",

pkg.module will point to a module that has ES2015 module syntax but otherwise only syntax features that the target environments support.
https://github.com/rollup/rollup/wiki/pkg.module

Wait, it just means import and export – not other future JavaScript features?
Yes. ...
https://github.com/rollup/rollup/wiki/pkg.module#wait-it-just-means-import-and-export--not-other-future-javascript-features

Babel allows you to disable just module syntax transpilation:
https://babeljs.io/docs/en/babel-preset-env#modules

And Rollup, Webpack etc can be configured to target a specific module syntax.

Suggestion (typescript): update types on AxiosRequestConfig

Something like this would help to avoid errors when trying to add options to axios instances options.

declare module 'axios' {
  export interface AxiosRequestConfig {
    raxConfig?: RetryConfig
  }
}

Today if we install the library using the example given in the readme it fails to compile ts.

import rax, { RetryConfig } from 'retry-axios';
import axios from 'axios';

export const myAxiosInstance = axios.create();
myAxiosInstance.defaults.raxConfig = { // <-- unkown property
  instance: myAxiosInstance
};
export const axiosRetryInterceptorId = rax.attach(myAxiosInstance);

Question: How do I use this with existing error interceptors?

This library looks like exactly what I need. I am trying it out with code like this:

rax.attach();

axios.defaults.raxConfig = {
  onRetryAttempt: err => {
    const cfg = rax.getConfig(err);
    console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
  }
};
axios.interceptors.response.use(interceptors.response.success, interceptors.response.error);`

interceptors.response.error is where I build up custom error for logging, which includes the request & response details. At the top I threw this in:

console.log(e.message);
console.log(typeof e.config);

When I purposefully error via gibberish URL the console.logs output this:

Retry attempt #1
Retry attempt #2
getaddrinfo ENOTFOUND www.asdlkfjaslfkjadflkjfadslfjnafdslkfasd.com www.asdlkfjaslfkjadflkjfadslfjnafdslkfasd.com:80
object
getaddrinfo ENOTFOUND www.asdlkfjaslfkjadflkjfadslfjnafdslkfasd.com www.asdlkfjaslfkjadflkjfadslfjnafdslkfasd.com:80
undefined

How should I ensure that my logic only runs after final attempt AND for any error that has no retries? ie an error with POST, which would never really run onRetryAttempt

Right now it looks to fire your plugin twice followed by my generic handler twice.

Cannot read property 'raxConfig' undefined

const rax = require('retry-axios'); const axios = require('axios');

    const response = await axios({
                method: 'post',
                url: url,
                headers: {
                    'Accept': 'application/json;charset=utf-8',
                    'Content-Type': 'application/json;charset=utf-8'
                },
                responseType: 'json',
                httpsAgent: new https.Agent({
                    rejectUnauthorized: false
                }),
                data: body,
                auth: {
                    username: user,

                    password: password,

                },
            }, );

ERROR :

stack:"TypeError: Cannot read property 'raxConfig' of undefined\n
odeceptjs\node_modules\retry-axios\build\src\index.js:29:31)\n at process._tickCallback (internal/process/next_tick.js:68:7)"

I set retry 3 times,but only retry 1 times

raxConfig: {
    retry: 3,
    noResponseRetries: 5,
    instance: http,
    retryDelay: 100,
    httpMethodsToRetry: ['GET', 'OPTIONS', 'POST'],
    shouldResetTimeout: false,
    onRetryAttempt: (err) => {
      const cfg = rax.getConfig(err);
      console.log(cfg.currentRetryAttempt);
    }
  }

Retry method not working when using two axios requests

When using two axios requests, the retry method works in the 1st request but doesn't work in 2nd request which is made after the 1st request. When calling the 2nd request an error is thrown and retry is not triggered.

Output: UnhandledPromiseRejectionWarning: Error: Request failed with status code 404

Exmaple:

` rax.attach();

const res = await axios({

url: 'https://postman-echo.com',

method: 'post',
raxConfig: {
// Retry 3 times on requests that return a response (500, etc) before giving up. Defaults to 3.
retry: 2,
// Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc).
noResponseRetries: 2,
// HTTP methods to automatically retry. Defaults to:
// ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
httpMethodsToRetry: ['GET', 'POST', 'HEAD', 'OPTIONS', 'DELETE', 'PUT'],
// The response status codes to retry. Supports a double
// array with a list of ranges. Defaults to:
// [[100, 199], [429, 429], [500, 599]]
statusCodesToRetry: [[100, 199], [400, 499], [500, 599]],
// Milliseconds to delay at first. Defaults to 100.
retryDelay: 100,
onRetryAttempt: (err) => {
const cfg = rax.getConfig(err);
console.log(Retry attempt #${cfg.currentRetryAttempt});
} } }); `

`
rax.attach();
const res = await axios({
url: 'https://postman-echo.com',
method: 'post',

raxConfig: {
// Retry 3 times on requests that return a response (500, etc) before giving up. Defaults to 3.
retry: 2,
// Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc).
noResponseRetries: 2,
// HTTP methods to automatically retry. Defaults to:
// ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
httpMethodsToRetry: ['GET', 'POST', 'HEAD', 'OPTIONS', 'DELETE', 'PUT'],
// The response status codes to retry. Supports a double
// array with a list of ranges. Defaults to:
// [[100, 199], [429, 429], [500, 599]]
statusCodesToRetry: [[100, 199], [400, 499], [500, 599]],
// Milliseconds to delay at first. Defaults to 100.
retryDelay: 100,
onRetryAttempt: (err) => {
const cfg = rax.getConfig(err);
console.log(Retry attempt #${cfg.currentRetryAttempt});
} } });`

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

TypeError: Cannot read property 'raxConfig' of undefined

Hey i am recieving this error im not sure why.

TypeError: Cannot read property 'raxConfig' of undefined

    const requestOptions = {
            url,
            method: "get",
            headers: {
                "X-IDCHECK-SESSION-ID": sessionId,
            },
        };

     requestOptions.raxConfig = {
       // Override the decision making process on if you should retry
       // Retry 3 times on requests that return a response (500, etc) before giving up.  Defaults to 3.
       retry: 3,

       // Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc).
       noResponseRetries: 2,

       // Milliseconds to delay at first.  Defaults to 100.
       retryDelay: 100,

       // HTTP methods to automatically retry.  Defaults to:
       // ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
       httpMethodsToRetry: ["GET", "HEAD", "OPTIONS", "DELETE", "PUT"],

       // The response status codes to retry.  Supports a double
       // array with a list of ranges.  Defaults to:
       // [[100, 199], [429, 429], [500, 599]]
       statusCodesToRetry: [
         [100, 199],
         [429, 429],
         [500, 599]
       ],

       // If you are using a non static instance of Axios you need
       // to pass that instance here (const ax = axios.create())
       // instance: ax,

       // You can detect when a retry is happening, and figure out how many
       // retry attempts have been made
       onRetryAttempt: (err) => {
         const cfg = getConfig(err);
         console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
       },
     };

     try {

       result = await axios(requestOptions);
     } catch(err) {
      console.log(err)
     }

url: '0.0.0.0:9999',
method: 'get',
headers: { 'X-IDCHECK-SESSION-ID': 5cd40e29268b04fc002c4575 },
raxConfig: {
  retry: 3,
  noResponseRetries: 2,
  retryDelay: 100,
  httpMethodsToRetry: [ 'GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT' ],
  statusCodesToRetry: [ [Array], [Array], [Array] ],
  onRetryAttempt: [Function: onRetryAttempt]
}
}

TypeError: Cannot read property 'raxConfig' of undefined
  at onError (/node_modules/retry-axios/src/index.ts:90:44)

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

How to retry ONLY `noResponseRetries`

I have a use-case where I only want to retry if it's ENOTFOUND, ETIMEDOUT, etc.

However, if I config:

retry: 0,
noResponseRetries: 3,

it doesn't attempt to retry on these errors at all.

Is there an easy way to configure it to retry these errors ONLY?

Error when a method called inside the axios interceptor throws a custom error

Error cannot read property 'raxConfig' of undefined is occurring when a method called inside the axios interceptor throws a custom error.

Example:
Interceptor:

axios.interceptors.request.use (
	async request => {
		request.headers.Authorization = await auth.getToken();
		return request
	},
	error => { ... }
);

Method (auth.getToken()):

	async getToken() {
		if (!this.auth.getCachedSession().isValid()) {
			throw new Error('Session has expired.');
		} else {
			return this.getAccessToken();
		}
	}

This error is happenning because custom error does not have a config object. Then the onError method of the retry-axios try to access error.config,raxConfig

A possible fix would be modifying onError function as following.

function onError(err) {
	if (!err.config) {
		return Promise.reject(err);
	}
        ...
}

How to use in React Component?

How can I use retry-axios in a React Component. If i follow the guideline by
import axios from 'axios'; import { rax } from 'retry-axios'; const interceptorId = rax.attach();
I get an error

Cannot read property 'attach' of undefined

at the line where I define const interceptorId = rax.attach();
Did anyone get it working in React?

Exception in function shouldRetryRequest() when checking HTTP methods to retry

In function shouldRetryRequest there's this block of code

    // Only retry with configured HttpMethods.
    if (!err.config.method ||
        config.httpMethodsToRetry.indexOf(err.config.method.toUpperCase()) < 0) {
        return false;
    }

that fails evaluating second condition, because httpMethodsToRetry is an object, not an array.

Below goes the output from dev console, when the breakpoint was set on the line given above ^^^:

config.httpMethodsToRetry
{0: "GET", 1: "HEAD", 2: "OPTIONS", 3: "DELETE", 4: "PUT"}

That looks different from what gets set in raxConfig

    const raxConfig = {
    ....
        
      // HTTP methods to automatically retry.  Defaults to:
      // ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
      httpMethodsToRetry: ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT'],
    }

Include an `isFinalRetry` property

When chain this interceptor with another global interceptor that displays an error message, it would be helpful to easily know if this request is the final retry of rax.

Currently, the logic to determine if the current retry is the final one is kind of complicated because of retries and noResponseRetries

Axios Timeout behaviour

We did not find any information about how the timeout acts when retry behaviour comes up.

given

axios.post(path, body, {
    baseURL: ur;,
    timeout: 12000,
    raxConfig: {
      retry: 5,
      retryDelay: 500,
    },

is the timeout of 12sec apply for all the 5 retries ? so 12 sec for performing 5 possible requests ?
or for each retry, the timeout is reset to 12sec ? being possibly 12sec * 5 attempts ?

can you please introduce this documentation in the main README ?

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.