Retry on HTTP 202 #1932
Answered
by
Caesarovich
Caesarovich
asked this question in
Q&A
-
Hello, I'm trying to trigger a retry on the 202 status code. Everything I've tried so far doesn't work, here's my client options retry: {
limit: 5,
calculateDelay: ({ attemptCount, computedValue }) => {
console.log(attemptCount, computedValue);
if (computedValue != 0) return attemptCount * 1000;
return 0;
},
statusCodes: [202, 408, 429, 500, 502, 503, 504, 521, 522, 524],
},
hooks: {
afterResponse: [
(response, retryWithMergedOptions) => {
// Queued
if (response.statusCode === 202) {
console.log('oops');
return retryWithMergedOptions(response.request.options);
}
// No changes otherwise
return response;
},
],
beforeRetry: [
() => {
console.log('before retry');
},
],
beforeError: [
(error) => {
console.log('BEFORE ERROR');
return error;
},
],
beforeRequest: [
() => {
console.log('before request: ');
},
],
}, The console logs outputs those:
And then it just proceeds to complete the promise without any sign of retrying. |
Beta Was this translation helpful? Give feedback.
Answered by
Caesarovich
Nov 29, 2021
Replies: 1 comment
-
Managed to pull it off i did not understand that I had to merge the client options and not request options. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Caesarovich
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Managed to pull it off i did not understand that I had to merge the client options and not request options.