adobe / adobe/target-nodejs-sdk
Retry logic is masking actual exception details when it encounters Timeout Exception.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 26
- Forks
- 22
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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));
});
};
}
```
Beitragsleitfaden
Rechercherichtung
Beginne mit networking.js und delivery-api-client/index.js und reproduziere dann das Problem mit einem 500ms-Timeout und ungültigen Target-Anforderungswerten. Verfolge, wie Wiederholungsversuche und das Timeout interagieren; abgeschlossen ist die Aufgabe, wenn die Details der zugrunde liegenden bad-request- oder SDK-Ausnahme weiterhin verfügbar sind und das Wiederholungsverhalten, sofern unterstützt, überschrieben werden kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100