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.

v5 menu select fails to update when menu is deleted

See original GitHub issue

Describe the bug I want just to report that probably this method needs some little exception handling, maybe just wrap it with a try/catch

menu.select(...
   set: async (ctx, selectedKey) => {
       // do stuff, like update cache, remote server values...
       // Now I need to close the menu. I am using this method (although I tried with ctx.deleteMessage() and it's just the same)
       await deleteMenuFromContext<Context>(ctx);
   })

This leads to unhandled promise rejection

(node:21113) UnhandledPromiseRejectionWarning: Error: 400: Bad Request: message to edit not found
    at /home/lamuertepeluda/Development/my-awsome-bot/node_modules/telegraf/core/network/client.js:281:17
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)
    at async MenuMiddleware.editMenuOnContext [as _sendMenu] (/home/lamuertepeluda/Development/my-awsome-bot/node_modules/telegraf-inline-menu/dist/source/send-menu.js:55:13)
    at async /home/lamuertepeluda/Development/my-awsome-bot/node_modules/telegraf-inline-menu/dist/source/menu-middleware.js:69:17
(node:21113) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:21113) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Versions Did you updated telegraf and telegraf-inline-menu to the latest version? “telegraf”: “^3.38.0”, “telegraf-inline-menu”: “^5.0.0-beta.5”, “telegraf-session-redis”: “^5.1.0”, “telegraf-stateless-question”: “^0.1.1”, “telegram-format”: “^2.0.0”

What version of NodeJS (and TypeScript) do you use?

  • Version of NodeJS: 12.18.0
  • Version of TypeScript: 3.9.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lamuertepeludacommented, Jun 25, 2020

Hi @EdJoPaTo , it works fine now: no exception thrown. Thank you.

1reaction
EdJoPaTocommented, Jun 9, 2020

I thought I already responded to this one… sorry about that.

Not the deletion of the message throws the error. The error is throws when the menu tries to do the job: showing the selection to the user by updating the menu. Updating a message which isnt there anymore. The error happens within the MenuMiddleware, more precisely within the editMenuOnContext function called by the MenuMiddleware. Its always a good idea to catch possible errors with bot.catch.

Taking a look about your choices towards the user close seems like a ‘non’ choice, something different. From only knowing that I would tend towards using a different button for that besides the selection / user choice.

select is basically a specific way of a choose: let the user choose something but also show the user afterwards what was done. If you dont want to use the feature of the select and do it yourself / differently then just stick to the more generic method choose there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accessing Actions Using Menu Elements - Apple Developer
Two items still need to be replaced: New Recipe and Delete Recipe. In this tutorial, you'll add these actions to the app's menu...
Read more >
Breaking changes in v5, part two: core components - Material UI
This is a reference guide to all of the breaking changes introduced in Material v5, and how to handle them when migrating from...
Read more >
Update existing projects to the latest release of the Windows ...
In Visual Studio 2019, click on Extensions -> Manage Extensions and select Updates from the left menu bar. Select "Project Reunion" from the ......
Read more >
No Access to ACER ASPIRE V5 471 Bios (Operating System ...
I encountered this problem today. Acer Aspire V5 will not display BIOS menu, no matter how many times you press F2, or whether...
Read more >
Failed to Remove Menu Item from Menu Builder #4071 - GitHub
Go to the Database and Create a Table. Go to BREAD Builder and Generate BREAD for the Recently added table. It will automatically...
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