question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Heroku incompatibility

See original GitHub issue
  • Telegraf.js Version: latest (3.29.0)
  • Node.js Version: 10.8.0
  • Operating System: win 8.1 64b (but deployed on Heroku)

The following code snippet misbehaves.

amountScene.hears(/^\s*(\d+)\s*$/, async ctx=>{
    console.log(ctx.message);
    await ctx.telegram.deleteMessage(ctx.message.chat.id, ctx.message.message_id)
    console.log('woooosh')
    if (ctx.match[1]>=ctx.session.service[0].MinOrder){
      ctx.session.amount = ctx.match[1]
      ctx.scene.enter('service')
    } else {
      tempMessage(ctx, resp.failedAmount(ctx.session.lang))
    }
  })

This handler is supposed to receive a text message like " 120", delete it, and if it complies with certain parameters, return to the previous scene while setting the session.amount to the received value.

Instead this code freezes the handler and it does not execute console.log('woooosh') or anything past it.

ctx.message always has the correct contents and gets output every time.

Removing await from ctx.telegram.deleteMessage() fixes the freeze, but the message still does not get deleted.

However, if I restart the app right before this handler gets used, the app deletes the message just fine. So like… it only deletes a message once every session.

I am using telegraf-session-mysql btw, but I don’t see how that’s relevant to ctx.telegram working in a weird way.

With long polling from local machine everything works smoothly, despite a huge latency instilled by my VPN setup.

Using bot.launch method as well as the old way does not make a difference.

Requesting support.

PS: This one-time “pool” seems to be shared between different telegram functions. For example ctx.answerCbQuery("hai bishh", true) also does not get executed except for the first time. And executing it also prevents deleteMessage() from working properly. But all my editMessageMedia calls do work, interestingly enough. Or sendPhoto. So it’s a very localized problem.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
TorlanDeltacommented, Jun 3, 2019

Also to note, the following block of code faces the same complications as the aforementioned ones.

userBot.on('text', (ctx) => {
    console.log('WOW SUCH MUCH BIG');
    ctx.reply(ctx.message.text)
  })

It works first time, but after that it requires a heroku restart to work again. What.Even.

1reaction
dotcypresscommented, Aug 12, 2019

Guys, please don’t forget to call all Telegraf function asynchronously:

// Wrong
userBot.on('text', (ctx) => {
    console.log('WOW SUCH MUCH BIG');
    ctx.reply(ctx.message.text)
  })

// Right
userBot.on('text', (ctx) => {
    console.log('WOW SUCH MUCH BIG');
    return ctx.reply(ctx.message.text)
  })

// Right as well
// Right
userBot.on('text', async (ctx) => {
    console.log('WOW SUCH MUCH BIG');
    await ctx.reply(ctx.message.text)
  })
Read more comments on GitHub >

github_iconTop Results From Across the Web

Heroku Python Support
Reference documentation describing the support for Python using Heroku's Python buildpack.
Read more >
Deploy to Heroku failed. move-file incompatible with node ...
I am struggling to deploy a new rails 6 app to heroku. It runs fine on my local. During the deployment process I...
Read more >
Problems with otree 3.x on Heroku because of incompatibility ...
Problems with otree 3.x on Heroku because of incompatibility with Python 3.9 ... command: /app/.heroku/python/bin/python -c 'import sys, setuptools, ...
Read more >
Heroku Compatibility - Scalingo
If your app works on Heroku, it will work on Scalingo. We have added several compatibility layers for that matter. Procfile If a...
Read more >
Why Did Heroku Fail? - Matt Rickard
If developers demand Heroku, why haven't they (or a competitor) figured out ... Heroku's business model was incompatible with its product.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found