Open ChuckJonas opened 1 year ago
I think it would be nice if we retry 429 errors by default... definitely a footgun that we do not.
think it would be nice if we retry 429 errors by default... definitely a footgun that we do not.
Typically, I'd leave that up to the consumer. Otherwise, it makes it harder to compose into circuit breakers
or more general async retry
frameworks.
If that feature was implemented, I would definitely want a way to configure it (number of retries, expo backoff, alternate server, etc) and would default it to off.
IMO, there are too many good libraries out there that support this already, this one should only be concerned with exposing the information needed to hook into those (raw request/response info)
Being configurable makes sense to me. My thinking is that having it on by default is a good, and users with more advanced usecases can just disable it and handle it themselves.
Right now the error handling only exposes the response body via the standard
Error
class.statusCode
I'd probably copy axios and do something like this:
Or maybe even just have properties for
status
,body
, etc if it's already been parsed/consumed.Then you can do something like this in your catch blocks: