nodejs icon indicating copy to clipboard operation
nodejs copied to clipboard

Retry on 5xx HTTP error

Open lojzatran opened this issue 4 years ago • 3 comments

nodejs sdk is currently retrying on 503 HTTP error only (https://github.com/commercetools/nodejs/blob/1167644b37db9af7baf511b8b14cdf6abf48f47c/packages/sdk-middleware-http/src/http.js#L215). According to the CTP documentation it should retry at least on 502 HTTP error (https://docs.commercetools.com/api/errors#502-bad-gateway). You may consider retrying also on other 5xx HTTP errors where it makes sense.

lojzatran avatar Dec 17 '21 16:12 lojzatran

Also is it possible to add own retry rules? E.g. we want to retry in some specific 4xx errors that we have confirmed from support that they should be retried. In the old sphere-node-sdk we have retryKeywords and we could also configure them: https://github.com/commercetools/sphere-node-sdk/blob/master/src/coffee/repeater-task-queue.coffee#L7. How could this be done in the current nodejs sdk?

lojzatran avatar Feb 03 '22 09:02 lojzatran

Hi @lojzatran

I will look into this and if it's something we need to implement I will raise a PR for it.

Thanks

ajimae avatar Feb 07 '22 11:02 ajimae

The question is how reliable is to have error codes only since some of the errors which are listed in the the old keywords SDK are not related to the API response code (since commercetools server is not reached) but also OS limitation like amount of possible concurrent connection and similar - in such cases it would allow the user to retry automatically too.

butenkor avatar Feb 14 '22 12:02 butenkor