How to use the @aws-sdk/service-error-classification.isThrottlingError function in @aws-sdk/service-error-classification

To help you get started, we’ve selected a few @aws-sdk/service-error-classification examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-sdk-js-v3 / packages / middleware-retry / src / defaultStrategy.ts View on Github external
next: FinalizeHandler,
    args: FinalizeHandlerArguments<input>
  ) {
    let retries = 0;
    let totalDelay = 0;
    while (true) {
      try {
        const { response, output } = await next(args);
        output.$metadata.retries = retries;
        output.$metadata.totalRetryDelay = totalDelay;

        return { response, output };
      } catch (err) {
        if (this.shouldRetry(err as SdkError, retries)) {
          const delay = this.delayDecider(
            isThrottlingError(err)
              ? THROTTLING_RETRY_DELAY_BASE
              : DEFAULT_RETRY_DELAY_BASE,
            retries++
          );
          totalDelay += delay;

          await new Promise(resolve =&gt; setTimeout(resolve, delay));
          continue;
        }

        if (!err.$metadata) {
          err.$metadata = {};
        }

        err.$metadata.retries = retries;
        err.$metadata.totalRetryDelay = totalDelay;
github aws / aws-sdk-js-v3 / packages / middleware-retry / src / retryDecider.ts View on Github external
if (error.connectionError) {
    return true;
  }

  if (
    hasMetadata(error) &&
    error.$metadata.httpStatusCode &&
    RETRYABLE_STATUS_CODES.has(error.$metadata.httpStatusCode)
  ) {
    return true;
  }

  return (
    isStillProcessingError(error) ||
    isThrottlingError(error) ||
    isClockSkewError(error)
  );
};

@aws-sdk/service-error-classification

[![NPM version](https://img.shields.io/npm/v/@aws-sdk/service-error-classification/latest.svg)](https://www.npmjs.com/package/@aws-sdk/service-error-classification) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/service-error-classification.svg)

Apache-2.0
Latest version published 1 year ago

Package Health Score

72 / 100
Full package analysis

Similar packages