retry-axios: 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'],
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 16 (4 by maintainers)
Commits related to this issue
- fixes #1 — committed to opyate/retry-axios by opyate 5 years ago
- fix: #1 — committed to opyate/retry-axios by opyate 5 years ago
- fix: #1 — committed to opyate/retry-axios by opyate 5 years ago
- fix: #1 — committed to opyate/retry-axios by opyate 5 years ago
@JustinBeckwith
v0.19.0-beta.1. Please see my comment. Now options are completely whitelisted and it doesn’t acceptraxConfig.I am also getting error,
Here is my relevant code,
And here is the error,
🎉 This issue has been resolved in version 2.0.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
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.
also had this issue. An effective workaround for the moment is to pass a custom shouldRetry function and check the type of
config.httpMethodsToRetryand get the values into something useful before checking. Not ideal, but relatively easy to fix until a new version of axios is released which resolves the issue.I am getting this, too.
Here’s my relevant code.
@mpyw shall we create separate issues for the peer dependency and whitelisting stuff?
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
httpMethodsToRetryandstatusCodesToRetryarrays to objects.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.