Skip to content

Commit 706d7b6

Browse files
authored
Merge pull request #483 from contentful/fix/retries
feat: enable 'fetch' adapter + duplicate request params fix
2 parents 514a1cd + 2fcb9f7 commit 706d7b6

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"@types/qs": "^6.9.10",
7575
"@typescript-eslint/eslint-plugin": "^5.11.0",
7676
"@typescript-eslint/parser": "^5.11.0",
77-
"axios": "^1.6.0",
77+
"axios": "^1.7.2",
7878
"axios-mock-adapter": "^1.20.0",
7979
"babel-eslint": "^10.1.0",
8080
"bundlesize": "^0.18.1",

src/rate-limit.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function rateLimit(instance: AxiosInstance, maxRetry = 5): void {
3030
responseLogger(response)
3131
return response
3232
},
33-
function (error) {
33+
async function (error) {
3434
const { response } = error
3535
const { config } = error
3636
responseLogger(error)
@@ -81,6 +81,14 @@ export default function rateLimit(instance: AxiosInstance, maxRetry = 5): void {
8181
delete config.httpAgent
8282
delete config.httpsAgent
8383

84+
/**
85+
* Hack to mitigate (likely) bug introduced in axios v1.7.0 where `url`,
86+
* when using the default `xhr` adapter, is a fully qualified URL (instead of a path),
87+
* which somehow causes the request params to be repeatedly appended
88+
* to the final request URL upon each retry.
89+
*/
90+
config.url = config.url.split('?')[0]
91+
8492
return delay(wait).then(() => instance(config))
8593
}
8694
return Promise.reject(error)

0 commit comments

Comments
 (0)