Skip to content

Commit

Permalink
fix(retryMiddleware): retry on fetch errors (@danny-larsen)
Browse files Browse the repository at this point in the history
Closes #58
  • Loading branch information
danny-larsen authored and nodkz committed May 22, 2018
1 parent 3af7e69 commit ad5c0db
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/middleware/retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ export default function retryMiddleware(options?: RetryMiddlewareOpts): Middlewa
return res;
})
.catch(err => {
if (err === timeoutError) {
const retryDelayMS = retryAfterMs(attempt);
if (retryDelayMS) {
logger(`response timeout, retrying after ${retryDelayMS} ms`);
return sendTimedRequest(timeout, retryDelayMS);
}
const retryDelayMS = retryAfterMs(attempt);
if (retryDelayMS) {
logger(`response timeout or network error, retrying after ${retryDelayMS} ms`);
return sendTimedRequest(timeout, retryDelayMS);
}

return new Promise((resolve, reject) => reject(err));
Expand Down

0 comments on commit ad5c0db

Please sign in to comment.