Skip to content

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

@saikiran11

Description

@saikiran11

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));
            });
        };
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions