retry

cart · /core·function

Built-in middleware that retries transport / provider failures with linear backoff. Errors matched by name to CartUserError, CartNotFoundError, and CartCapabilityUnsupportedError propagate immediately — they are deterministic and a retry would never resolve them. All other errors retry up to attempts times; on final failure the last error is rethrown.

Signature

@nordcom/commerce-cart
function retry(opts: { attempts: number; backoffMs: number }): CartMiddleware;

Parameters

NameTypeDescription
opts{ attempts: number; backoffMs: number }

Returns

A that retries retryable failures.

Example

const kernel = createCart({
  adapter,
  middleware: [retry({ attempts: 3, backoffMs: 200 })],
});

RunCartAdapterContractOpts runCartAdapterContract CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter

On this page