Octokit plugin for GitHub’s recommended request retries
Installations
npm install @octokit/plugin-retry
Developer
octokit
Developer Guide
Module System
ESM
Min. Node Version
>= 18
Typescript Support
Yes
Node Version
20.17.0
NPM Version
10.8.3
Statistics
38 Stars
604 Commits
18 Forks
12 Watching
8 Branches
24 Contributors
Updated on 26 Nov 2024
Languages
TypeScript (88.17%)
JavaScript (11.83%)
Total Downloads
Cumulative downloads
Total Downloads
153,188,712
Last day
-4.5%
392,707
Compared to previous day
Last week
4.3%
2,322,796
Compared to previous week
Last month
9.2%
9,756,869
Compared to previous month
Last year
118.1%
91,035,336
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
plugin-retry.js
Retries requests for server 4xx/5xx responses except
400
,401
,403
,404
,422
, and451
.
Usage
Browsers |
Load
|
---|---|
Node |
Install with
|
[!IMPORTANT] As we use conditional exports, you will need to adapt your
tsconfig.json
by setting"moduleResolution": "node16", "module": "node16"
.See the TypeScript docs on package.json "exports".
See this helpful guide on transitioning to ESM from @sindresorhus
1const MyOctokit = Octokit.plugin(retry); 2const octokit = new MyOctokit({ auth: "secret123" }); 3 4// retries request up to 3 times in case of a 500 response 5octokit.request("/").catch((error) => { 6 if (error.request.request.retryCount) { 7 console.log( 8 `request failed after ${error.request.request.retryCount} retries`, 9 ); 10 } 11 12 console.error(error); 13});
To override the default doNotRetry
list:
1const octokit = new MyOctokit({ 2 auth: "secret123", 3 retry: { 4 doNotRetry: [ 5 /* List of HTTP 4xx/5xx status codes */ 6 ], 7 }, 8});
To override the number of retries:
1const octokit = new MyOctokit({ 2 auth: "secret123", 3 request: { retries: 1 }, 4});
You can manually ask for retries for any request by passing { request: { retries: numRetries, retryAfter: delayInSeconds }}
. Note that the doNotRetry
option from the constructor is ignored in this case, requests will be retried no matter their response code.
1octokit 2 .request("/", { request: { retries: 1, retryAfter: 1 } }) 3 .catch((error) => { 4 if (error.request.request.retryCount) { 5 console.log( 6 `request failed after ${error.request.request.retryCount} retries`, 7 ); 8 } 9 10 console.error(error); 11 });
Pass { retry: { enabled: false } }
to disable this plugin.
Contributing
See CONTRIBUTING.md
License
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
20 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:14
Reason
SAST tool is run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Info: all commits (30) are checked with a SAST tool
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy
- Info: Found text in security policy: SECURITY.md:1
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/add_to_octokit_project.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/add_to_octokit_project.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/codeql-analysis.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/immediate-response.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/immediate-response.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-prettier.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/update-prettier.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-prettier.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/update-prettier.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/update-prettier.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/octokit/plugin-retry.js/update-prettier.yml/main?enable=pin
- Info: 0 out of 12 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 4 out of 4 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29
- Warn: no topLevel permission defined: .github/workflows/add_to_octokit_project.yml:1
- Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1
- Warn: topLevel 'contents' permission set to 'write': .github/workflows/release.yml:8
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Warn: no topLevel permission defined: .github/workflows/update-prettier.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Score
7.7
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More