From 6305de4fc8951fd89247e8319b134d3a7be29c83 Mon Sep 17 00:00:00 2001 From: Nikhil Pandit Date: Tue, 7 Aug 2018 15:14:30 -0700 Subject: [PATCH] retry even if there is an error --- VERSION | 5 ++--- _hardcoded/doer.go | 4 ++-- clients/js/genjs.go | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index 5d0bc52d..f825da10 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,2 @@ -v1.10.1 -- fixup in formatting -- Allow setting keepalive in node clients +v1.11.0 +- retry even if there is an error diff --git a/_hardcoded/doer.go b/_hardcoded/doer.go index a9cf1975..8a79e0e0 100644 --- a/_hardcoded/doer.go +++ b/_hardcoded/doer.go @@ -87,7 +87,7 @@ func (SingleRetryPolicy) Backoffs() []time.Duration { // Retry will retry non-POST, non-PATCH requests that 5XX. // TODO: It does not currently retry any errors returned by net/http.Client's `Do`. func (SingleRetryPolicy) Retry(req *http.Request, resp *http.Response, err error) bool { - if err != nil || req.Method == "POST" || req.Method == "PATCH" || + if req.Method == "POST" || req.Method == "PATCH" || resp.StatusCode < 500 { return false } @@ -114,7 +114,7 @@ func (ExponentialRetryPolicy) Backoffs() []time.Duration { // Retry will retry non-POST, non-PATCH requests that 5XX. // TODO: It does not currently retry any errors returned by net/http.Client's `Do`. func (ExponentialRetryPolicy) Retry(req *http.Request, resp *http.Response, err error) bool { - if err != nil || req.Method == "POST" || req.Method == "PATCH" || + if req.Method == "POST" || req.Method == "PATCH" || resp.StatusCode < 500 { return false } diff --git a/clients/js/genjs.go b/clients/js/genjs.go index 7a208f0b..e54ee3ae 100644 --- a/clients/js/genjs.go +++ b/clients/js/genjs.go @@ -114,7 +114,7 @@ const exponentialRetryPolicy = { return ret; }, retry(requestOptions, err, res) { - if (err || requestOptions.method === "POST" || + if (requestOptions.method === "POST" || requestOptions.method === "PATCH" || res.statusCode < 500) { return false; @@ -132,7 +132,7 @@ const singleRetryPolicy = { return [1000]; }, retry(requestOptions, err, res) { - if (err || requestOptions.method === "POST" || + if (requestOptions.method === "POST" || requestOptions.method === "PATCH" || res.statusCode < 500) { return false;