-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
I am setting timeout to 500ms for target SDK requests but unable to get exception details when there are bad request or other exceptions that SDK is throwing. SDK is internally adding retry logic while making AT delivery API calls, if the configured timeout period is less than the time takes to complete retries (10=maximum number of retries) then the actual exception details are masked with Timeout exception.
Is there anyway we can override retry mechanism?
Reproduce Scenario (including but not limited to)
Set Timeout to lower number and make Target request with invalid values. The SDK returns Timeout exception and does not provides Bad request details.
Platform and Version
2.1.6
//networking.js
export function getFetchWithRetry( fetchApi, maxRetries = DEFAULT_NUM_FETCH_RETRIES, errorFunc = errorMessage => errorMessage, incidentalFailureCallback = noop) { return function fetchWithRetry(url, options, numRetries = maxRetries) { return fetchApi(url, options) .then(res => { if (!res.ok && res.status !== NOT_MODIFIED) { throw Error(res.statusText); } return res; }) .catch(err => { if (isFunction(incidentalFailureCallback)) { incidentalFailureCallback.call(undefined, err); }
if (numRetries < 1) { throw new Error(errorFunc(err.message)); } // TODO: Enhance this to do Exponential Backoff return fetchWithRetry(url, options, numRetries - 1); }); };}
//delivery-api-client/index.js
get fetchApi() {
const timeout = this.configuration.timeout;
const fetch = this.configuration.fetchApi || window.fetch.bind(window);
return function (input, init) {
return new Promise((resolve, reject) => {
**let timer = setTimeout(() => reject(new Error('Request timed out')), timeout);**
fetch(input, init).then(response => resolve(response), err => reject(err)).finally(() => clearTimeout(timer));
});
};
}
saeed-alam
Metadata
Metadata
Assignees
Labels
No labels