Skip to content

Commit cd5c994

Browse files
fix(ratelimit): Only retry on 500
1 parent 5fc9143 commit cd5c994

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/rate-limit.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ export default function rateLimit (instance, maxRetry = 10) {
1212
// in axios reponse will be available only if there a response from server
1313
// in this case will assume it is a 500 error
1414
error.response = error.response || {status: 500}
15-
16-
if (error.response.status >= 500) {
15+
if (error.response.status === 500) {
1716
attempt++
1817
lastErrorAt = lastErrorAt || Date.now()
1918
if (Date.now() - lastErrorAt >= 30000) {
@@ -28,7 +27,7 @@ export default function rateLimit (instance, maxRetry = 10) {
2827
}
2928

3029
// retry if we receive 429 or 500
31-
if (error.response.status === 429 || error.response.status >= 500) {
30+
if (error.response.status === 429 || error.response.status === 500) {
3231
var rateLimitHeaderValue = 0
3332
// all headers are lowercased by axios https://github.com/mzabriskie/axios/issues/413
3433
if (error.response.headers && error.response.headers['x-contentful-ratelimit-reset']) {

0 commit comments

Comments
 (0)