Skip to content

Commit

Permalink
Merge pull request #26 from lozlow/retry-successful-requests
Browse files Browse the repository at this point in the history
Allow retries on successful requests
  • Loading branch information
ryanashcraft authored Mar 8, 2017
2 parents 83865e8 + 79ebd01 commit 6fc3412
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/middleware/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,29 @@ const queryMiddleware = (queriesSelector, entitiesSelector, config = defaultConf
const resBody = (response && response.body) || undefined;
const resText = (response && response.text) || undefined;

if (
includes(config.retryableStatusCodes, resStatus) &&
attempts < config.backoff.maxAttempts
) {
// TODO take into account Retry-After header if 503
setTimeout(attemptRequest, backoff.duration());
return;
}

let transformed;
let newEntities;

if (err || !resOk) {
if (
includes(config.retryableStatusCodes, resStatus) &&
attempts < config.backoff.maxAttempts
) {
// TODO take into account Retry-After header if 503
setTimeout(attemptRequest, backoff.duration());
} else {
dispatch(
requestFailure(
url,
body,
resStatus,
resBody,
meta,
queryKey
)
);
}
dispatch(
requestFailure(
url,
body,
resStatus,
resBody,
meta,
queryKey
)
);
} else {
const callbackState = getState();
const entities = entitiesSelector(callbackState);
Expand Down

0 comments on commit 6fc3412

Please sign in to comment.