@grammyjs/auto-retry
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Automatically Retry grammY API Requests

Check out the official documentation for this grammY plugin.

Quickstart

An API transformer function let's you modify outgoing HTTP requests on the fly. This grammY plugin can automatically detect if an API requests fails with a retry_after value. It will then intercept the error, wait the specified period of time, and then retry the request.

import { autoRetry } from '@grammyjs/auto-retry'

// Install the plugin
bot.api.config.use(autoRetry())

You may pass an options object that specifies a maximum number of retries (maxRetryAttempts, default: 3), or a threshold for a maximal time to wait (maxDelaySeconds, default: 1 hour). Other errors will be passed on, so the request will fail.

autoRetry({
    maxRetryAttempts: 1,
    maxDelaySeconds: 5,
})

You can use retryOnInternalServerErrors to automatically retry all other internal server errors by Telegram (status code >= 500).

Package Sidebar

Install

npm i @grammyjs/auto-retry

Weekly Downloads

1,335

Version

1.1.1

License

MIT

Unpacked Size

6.36 kB

Total Files

4

Last publish

Collaborators

  • knorpelsenf