Skip to content

grammY API transformer function to retry requests

License

Notifications You must be signed in to change notification settings

RemusGrigorescu/auto-retry

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

About

grammY API transformer function to retry requests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%