SalesforceCommerceCloud / commerce-sdk

https://salesforcecommercecloud.github.io/commerce-sdk/
BSD 3-Clause "New" or "Revised" License
149 stars 48 forks source link

retrySettings doesn't work #408

Closed ben-optus closed 1 month ago

ben-optus commented 3 months ago
 const client = new Customer.ShopperLogin(
    this.configsService.getConfig(undefined, 'shopper/auth', env),
  );
  const result = await client.getAccessToken({
    headers,
    body: {
      grant_type: 'client_credentials',
      channel_id: API_SITE_ID,
    },
   retrySettings: {
     retries: 3,
     minTimeout: 10000
   }
  });

with above retrySettings, no retry is happening  
joeluong-sfcc commented 1 month ago

Hi @ben-optus, thanks for creating this issue. Under the hood, the commerce-sdk makes fetch calls using this package:

https://www.npmjs.com/package/make-fetch-happen

in the official documentation for make-fetch-happen, It states that retries are only triggered under the following conditions:

Request method is NOT POST AND
Request status is one of: 408, 420, 429, or any status in the 500-range. OR
Request errored with ECONNRESET, ECONNREFUSED, EADDRINUSE, ETIMEDOUT, or the fetch error request-timeout.

For now I'll be closing out this issue, but feel free to re open if the getAccessToken call meets those retry conditions and still does not retry.