Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@octokit/plugin-retry

Package Overview
Dependencies
Maintainers
3
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/plugin-retry

Automatic retry plugin for octokit

Source
npmnpm
Version
2.1.2
Version published
Weekly downloads
7.9M
0.66%
Maintainers
3
Weekly downloads
 
Created
Source

plugin-retry.js

npm Build Status Coverage Status Greenkeeper

Implements request retries for server 4xx/5xx responses except 400, 401, 403 and 404.

Usage

const Octokit = require('@ocotkit/rest')
  .plugin(require('@octokit/plugin-retry'))

const octokit = new Octokit()

// retries request up to 3 times in case of a 500 response
octokit.request('/').catch(error => {
  if (error.request.request.retryCount) {
    console.log(`request failed after ${error.request.request.retryCount} retries`)
  }

  console.error(error)
})

To override the default doNotRetry list:

const octokit = new Octokit({
  retry: {
    doNotRetry: [ /* List of HTTP 4xx/5xx status codes */ ]
  }
})

You can manually ask for retries for any request by passing { request: { retries: numRetries, retryAfter: delayInSeconds }}

octokit.request('/', { request: { retries: 1, retryAfter: 1 } }).catch(error => {
  if (error.request.request.retryCount) {
    console.log(`request failed after ${error.request.request.retryCount} retries`)
  }

  console.error(error)
})

Pass { retry: { enabled: false } } to disable this plugin.

LICENSE

MIT

FAQs

Package last updated on 01 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts