How to use the p-retry.AbortError function in p-retry

To help you get started, we’ve selected a few p-retry 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 kellyselden / create-react-app-updater / src / get-package-versions.js View on Github external
await pRetry(async() => {
      let results;

      try {
        results = await npm(`view ${parentPackageName}@${_parentVersion} dependencies --json`);
      } catch (err) {
        // occurs sometimes when running multiple npm calls at once
        if (typeof err !== 'string' || !err.includes('npm update check failed')) {
          throw new pRetry.AbortError(err);
        }

        // https://github.com/sindresorhus/p-retry/issues/14
        // throw err;
        throw new Error(err);
      }

      if (parentVersion) {
        return;
      }

      // some versions may be missing deps
      if (!results) {
        return;
      }
github webiny / webiny-js / components / serverless-aws-api-gateway / utils.js View on Github external
async () => {
            try {
                return await fn();
            } catch (error) {
                if (error.code !== "TooManyRequestsException") {
                    // Stop retrying and throw the error
                    throw new pRetry.AbortError(error);
                }
                throw error;
            }
        },
        {
github open-voip-alliance / WebphoneLib / src / transport.ts View on Github external
const retryForever = pRetry(() => {
      // It could happen that this function timed out. Because this is a
      // async function we check the client status to stop this loop.
      if (this.status === ClientStatus.DISCONNECTED) {
        throw new pRetry.AbortError("It's no use. Stop trying to recover");
      }

      return tryOpeningSocketWithTimeout();
    }, retryOptions);
github kellyselden / create-react-app-updater / src / get-package-version.js View on Github external
}).catch(err => {
            // occurs sometimes when running multiple npm calls at once
            if (typeof err !== 'string' || !err.includes('npm update check failed')) {
              throw new pRetry.AbortError(err);
            }

            // https://github.com/sindresorhus/p-retry/issues/14
            // throw err;
            throw new Error(err);
          });
        }, { retries: 5 });
github sourcegraph / sourcegraph / lsif / src / shared / store / uploads.ts View on Github external
const checkUploadState = async (): Promise => {
            const upload = await instrumentQuery(() =>
                this.connection.getRepository(pgModels.LsifUpload).findOneOrFail({ id: uploadId })
            )

            if (upload.state === 'errored') {
                const error = new Error(upload.failureSummary)
                error.stack = upload.failureStacktrace
                throw new AbortError(error)
            }

            if (upload.state !== 'completed') {
                throw new UploadInProgressError()
            }
        }
github nasa / cumulus / packages / common / CloudFormationGateway.js View on Github external
async () => {
        try {
          const stackDetails = await cloudFormationService.describeStacks({
            StackName
          }).promise();

          return stackDetails.Stacks[0].StackStatus;
        } catch (err) {
          if (isThrottlingException(err)) throw new Error('Trigger retry');
          throw new pRetry.AbortError(err);
        }
      },
      {
github nasa / cumulus / example / spec / helpers / kinesisHelpers.js View on Github external
async () => {
      try {
        return kinesis.createStream({ StreamName: streamName, ShardCount: 1 }).promise();
      } catch (error) {
        if (error.code === 'LimitExceededException') throw new Error('Trigger retry');
        throw new pRetry.AbortError(error);
      }
    },
    {
github googleapis / nodejs-spanner / src / database.js View on Github external
.catch(e => {
          if (e.code === Transaction.ABORTED) throw e;
          throw new retry.AbortError(e.message);
        })
    );
github faceit-enhancer / faceit-enhancer / src / content / helpers / faceit-api.js View on Github external
fetch(`${BASE_URL}${path}`, options).then(res => {
          if (res.status === 404) {
            throw new pRetry.AbortError(res.statusText)
          } else if (!res.ok) {
            throw new Error(res.statusText)
          }
          return res
        }),
      {
github webiny / webiny-js / packages-utils / webiny-semantic-release / src / plugins / github / utils / githubClient.js View on Github external
return pRetry(async () => {
            try {
                return await throttler.wrap(func)(...args);
            } catch (err) {
                if (SKIP_RETRY_CODES.includes(err.code)) {
                    throw new pRetry.AbortError(err);
                }
                throw err;
            }
        }, retry);
    }

p-retry

Retry a promise-returning or async function

MIT
Latest version published 5 months ago

Package Health Score

80 / 100
Full package analysis

Popular p-retry functions