Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry logic is masking actual exception details when it encounters Timeout Exception. #55

Open
saikiran11 opened this issue Jun 21, 2021 · 0 comments

Comments

@saikiran11
Copy link

saikiran11 commented Jun 21, 2021

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));
            });
        };
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant