-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception in function shouldRetryRequest() when checking HTTP methods to retry #1
Comments
Weird. |
I am getting this, too. Here's my relevant code. import Axios from 'axios';
import { attach as raxAttach, getConfig as raxConfig } from 'retry-axios';
const createAxios = () => {
const http = Axios.create();
http.defaults.timeout = 60*1000;
http.defaults.validateStatus = (status) => (status >= 200 && status < 300) || (status == 404);
http.defaults.raxConfig = {
instance: http,
retry: 5,
noResponseRetries: 100,
retryDelay: 250,
httpStatusCodesToRetry: [[100, 199], [420, 429], [500, 599]],
onRetryAttempt: (err) => {
try {
console.info("Retrying request", err, raxConfig(err))
} catch(e) {
throw new Error("Error logging the retry of a request: " + e);
}
},
};
raxAttach(http);
return http;
}; |
I am also getting error, Here is my relevant code,
And here is the error,
|
I debugged this issue and found the root of the problem in the Axios package. The issue only happens on retry, and the reason is because of a configuration merge function that converts the Offending line here: https://github.com/axios/axios/blob/ad1195f0702381a77b4f2863aad6ddb1002ffd51/lib/core/Axios.js#L35 It appears that this merge function has entirely changed (with deep-copy fixes) for v0.18.x releases, which are yet to be released. |
also had this issue. An effective workaround for the moment is to pass a custom shouldRetry function and check the type of |
config = mergeConfig(this.defaults, config); module.exports = function mergeConfig(config1, config2) {
// eslint-disable-next-line no-param-reassign
config2 = config2 || {};
var config = {};
utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
}
});
utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
if (utils.isObject(config2[prop])) {
config[prop] = utils.deepMerge(config1[prop], config2[prop]);
} else if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
} else if (utils.isObject(config1[prop])) {
config[prop] = utils.deepMerge(config1[prop]);
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
}
});
utils.forEach([
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
'socketPath'
], function defaultToConfig2(prop) {
if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
}
});
return config;
}; |
@opyate The same problem exists with the |
Having this problem as well |
@georgyfarniev I abondoned |
I also propose that peer dependency be correctly defined with a specific version. "peerDependencies": {
"axios": "*" // <- ??
}, |
Greetings! When you say the latest version - what specific version are you using? |
|
@mpyw shall we create separate issues for the peer dependency and whitelisting stuff? |
Do you guys know of a drop in (or as close to drop in as possible) replacement for axios? This library is on the critical path for a lot of our apps, and problems like these cause serious issues and slow down development. |
I wrote https://github.com/googleapis/gaxios/ to be that drop in replacement based on node-fetch 🙃 It's part of the reason I don't spend a ton of time in this particular module. It has retries baked in. |
🎉 This issue has been resolved in version 2.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
In function
shouldRetryRequest
there's this block of codethat 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 ^^^:
That looks different from what gets set in
raxConfig
The text was updated successfully, but these errors were encountered: