telegraf: TimeoutError: Promise timed out after 90000 milliseconds

  • Telegraf.js Version: 4.3.0
  • Node.js Version: 14.16.1
  • Operating System: win10

Minimal Example Code Reproducing the Issue

image image

I think this happens if you upload large files with slow internet

Expected Behavior

The files must be uploaded to the telegram servers, sent to the user, return the array of uploaded files

Current Behavior

The files were uploaded to the telegram servers, sent to the user. But this error returned. No file array returned. The execution of further code has been abandoned due to an error. image

Error Message and Logs (export DEBUG='telegraf:*')

I do not have

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 36 (4 by maintainers)

Most upvoted comments

telegraf is using a p-timeout for Promises (https://github.com/telegraf/telegraf/blob/v4/src/telegraf.ts#L232) By default:

const DEFAULT_OPTIONS: Telegraf.Options<Context> = {
  telegram: {},
  handlerTimeout: 90_000, // 90s in ms
  contextType: Context,
}

Use export const bot = new Telegraf(BOT_TOKEN, {handlerTimeout: 9_000_000}); Where handlerTimeout (for example) is 2.5 hours

@AliAryanTech

const bot = new Telegraf(token, {
  handlerTimeout: Infinity // or Number.POSITIVE_INIFINITY
})

I see, thanks

@AliAryanTech

const bot = new Telegraf(token, {
  handlerTimeout: Infinity // or Number.POSITIVE_INIFINITY
})

@gthrm Нow will this solve the problem if 1000 users simultaneously hang for 2.5 hours waiting? How to solve the problem globally so that you can just catch this exception?

It’s about “TimeoutError: Promise timed out after 90000 milliseconds”. Not about catch and 1000 users. For example, for 1000 users you can create a queue. And create PR for fix situation with catch. You know?

@AliAryanTech Lol it’s true, sorry xd

I use

bot.catch(e => {
  console.log("aaaaaaaaaaaaaaaaaaaa");
});

Interesting discussion

@gthrm Нow will this solve the problem if 1000 users simultaneously hang for 2.5 hours waiting? How to solve the problem globally so that you can just catch this exception? I get such an error on ctx.reply, when the user clicks on the inline button during the period when about 100 users simultaneously knock on the bot at the same time

My hypothesis is correct, that this is due to the slow internet. It turns out I had VPN turned on.