# @octokit/plugin-retry

> Automatic retry plugin for octokit

Latest version **8.1.1** (published 2026-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @octokit/plugin-retry
pnpm add @octokit/plugin-retry
yarn add @octokit/plugin-retry
bun add @octokit/plugin-retry
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 8.1.1 |
| Published | 2026-08-01 |
| First published | 2018-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >= 20 |
| Dependencies | 3 |
| Unpacked size | 17.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 48 |
| Author | Simon Grondin |
| Maintainers | octokitbot, gr2m, wolfy1339 |

## Links

- npm: https://www.npmjs.com/package/@octokit/plugin-retry
- Repository: https://github.com/octokit/plugin-retry.js
- Homepage: https://github.com/octokit/plugin-retry.js#readme
- Issues: https://github.com/octokit/plugin-retry.js/issues
- npm.io page: https://npm.io/package/@octokit/plugin-retry

## Dependencies (3)

- [bottleneck](https://npm.io/package/bottleneck.md) ^2.15.3
- [@octokit/types](https://npm.io/package/@octokit/types.md) ^17.0.0
- [@octokit/request-error](https://npm.io/package/@octokit/request-error.md) ^7.1.1

## Recent versions

- 8.1.1 (latest) — 2026-08-01
- 6.1.0 (release-6.x) — 2024-11-29
- 8.1.0 — 2026-02-18
- 8.0.3 — 2025-10-31
- 8.0.2 — 2025-09-29
- 8.0.1 — 2025-05-20
- 8.0.0 — 2025-05-20
- 7.2.1 — 2025-04-10
- 7.2.0 — 2025-03-18
- 7.1.4 — 2025-02-14
- 7.1.3 — 2025-01-07
- 7.1.2 — 2024-09-18
- 7.1.1 — 2024-04-23
- 7.1.0 — 2024-04-03
- 7.0.4 — 2024-04-03
- … 37 more at https://npm.io/package/@octokit/plugin-retry/versions

## README

# plugin-retry.js

> Retries requests for server 4xx/5xx responses except `400`, `401`, `403`, `404`, `410`, `422`, and `451`.

[![@latest](https://img.shields.io/npm/v/@octokit/plugin-retry.svg)](https://www.npmjs.com/package/@octokit/plugin-retry)
[![Build Status](https://github.com/octokit/plugin-retry.js/workflows/Test/badge.svg)](https://github.com/octokit/plugin-retry.js/actions?workflow=Test)

## Usage

<table>
<tbody valign=top align=left>
<tr><th>
Browsers
</th><td width=100%>

Load `@octokit/plugin-retry` and [`@octokit/core`](https://github.com/octokit/core.js) (or core-compatible module) directly from [esm.sh](https://esm.sh)

```html
<script type="module">
  import { Octokit } from "https://esm.sh/@octokit/core";
  import { retry } from "https://esm.sh/@octokit/plugin-retry";
</script>
```

</td></tr>
<tr><th>
Node
</th><td>

Install with `npm install @octokit/core @octokit/plugin-retry`. Optionally replace `@octokit/core` with a core-compatible module

```js
import { Octokit } from "@octokit/core";
import { retry } from "@octokit/plugin-retry";
```

</td></tr>
</tbody>
</table>

> [!IMPORTANT]
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`.
>
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)

```js
const MyOctokit = Octokit.plugin(retry);
const octokit = new MyOctokit({ auth: "secret123" });

// 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:

```js
const octokit = new MyOctokit({
  auth: "secret123",
  retry: {
    doNotRetry: [
      /* List of HTTP 4xx/5xx status codes */
    ],
  },
});
```

To override the number of retries:

```js
const octokit = new MyOctokit({
  auth: "secret123",
  request: { retries: 1 },
});
```

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.

```js
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.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/@octokit/plugin-retry · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
