fetch-retry icon indicating copy to clipboard operation
fetch-retry copied to clipboard

Don't retry upon *any* 5xx status code

Open rauchg opened this issue 6 years ago • 6 comments

501 for example means Not Implemented. ie: not worth retrying.

500 502 503 504

make sense instead.

rauchg avatar Dec 04 '17 00:12 rauchg

Retry on 502 makes sense at least with our proxies because IIRC it usually means that the backend service is temporarily down.

OlliV avatar Dec 04 '17 20:12 OlliV

also 503 (503 is iirc what we give if unfreeze is taking too long (and 502 when there is an issue which is less likely to solve on it's own)

And also 500 might be worth retrying since it's the generic something went wrong (but in that case a longer/steeper retry would make sense. for cases like "overloaded cosmos" etc

jamo avatar Dec 04 '17 20:12 jamo

@OlliV that's exactly what I said. We should retry on the ones I listed, but not on any 50x, for example not 501.

rauchg avatar Dec 13 '17 17:12 rauchg

Retrying within fetch depending on status code does not make sense at all. A response with a status code is a successfully executed request regardless of the status code. Analyzing and responding to status code lies in application layer, not baked inside plumbing such as fetch.

msz avatar Dec 05 '18 13:12 msz

That's why maybe opts could contain a "retryIf" function that gets the response and tells if it should retry. If one hands in an array of numbers then this implicit for a function checking those status codes.

pke avatar Sep 18 '21 21:09 pke

Retrying was implemented here because it made sense to have a shared module that can do it for the backend code at the company, instead of copying and pasting the same handling to every service. Now you see that this is actually a separate module, and not "baked in" feature, so you can easily just drop it and use the other parts of the modular library. There was an example somewhere in the README files.

OlliV avatar Sep 23 '21 09:09 OlliV