softonic / axios-retry

Axios plugin that intercepts failed requests and retries them whenever possible
Other
1.9k stars 167 forks source link

[discuss] 511 error neet retry? #153

Open liuestc opened 4 years ago

liuestc commented 4 years ago

about 511, wiki description:

5xxerror

511 Network Authentication Required (RFC 6585) The client needs to authenticate to gain network access. Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).[59]

so i think if occur the authenticate error, we dont't need retry

export function isRetryableError(error) {
  return (
    error.code !== 'ECONNABORTED' &&
    (!error.response || (error.response.status >= 500 && error.response.status <= 599))
  );
}

btw,the 511 is biggest error code in 5xx

so I think

error.response.status >= 500 && error.response.status <= 510 is better

fabiofdsantos commented 4 years ago

You have the HTTP 521 of Cloudflare which is a service widely used