Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle events that have no reply methods #8

Open
armand1m opened this issue Jun 27, 2021 · 1 comment
Open

Handle events that have no reply methods #8

armand1m opened this issue Jun 27, 2021 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@armand1m
Copy link
Owner

Describe the bug
In some situations, such as an user being kicked, the Telegraf might not offer a reply command. Currently we check for the method, but that is not enough to avoid an unhandled error.

2021-06-26T12:50:53.562951998Z Unhandled error while processing {
2021-06-26T12:50:53.563009733Z update_id: 123123123,
2021-06-26T12:50:53.563018894Z my_chat_member: {
2021-06-26T12:50:53.563024756Z chat: {
2021-06-26T12:50:53.563030413Z id: 123123123,
2021-06-26T12:50:53.563036079Z first_name: 'xxx',
2021-06-26T12:50:53.563041836Z username: 'xxx',
2021-06-26T12:50:53.563047756Z type: 'private'
2021-06-26T12:50:53.563053455Z },
2021-06-26T12:50:53.563058913Z from: {
2021-06-26T12:50:53.563093910Z id: 123123123,
2021-06-26T12:50:53.563103325Z is_bot: false,
2021-06-26T12:50:53.563109439Z first_name: 'xxx',
2021-06-26T12:50:53.563115336Z username: 'xxx',
2021-06-26T12:50:53.563127054Z },
2021-06-26T12:50:53.563132867Z date: 1624711853,
2021-06-26T12:50:53.563138397Z old_chat_member: { user: [Object], status: 'member' },
2021-06-26T12:50:53.563143952Z new_chat_member: { user: [Object], status: 'kicked', until_date: 0 }
2021-06-26T12:50:53.563149705Z }
2021-06-26T12:50:53.563155505Z }
2021-06-26T12:50:53.671017986Z (node:1) UnhandledPromiseRejectionWarning: TypeError: Telegraf: "reply" isn't available for "undefined"
2021-06-26T12:50:53.671091073Z at Context.assert (/app/node_modules/telegraf/lib/context.js:110:19)
2021-06-26T12:50:53.671103377Z at Context.reply (/app/node_modules/telegraf/lib/context.js:166:14)
2021-06-26T12:50:53.671108968Z at /app/build/middlewares/createContextMiddleware.js:20:24
2021-06-26T12:50:53.671115031Z at Generator.next (<anonymous>)
2021-06-26T12:50:53.671121529Z at /app/node_modules/tslib/tslib.js:117:75
2021-06-26T12:50:53.671127704Z at new Promise (<anonymous>)
2021-06-26T12:50:53.671162993Z at Object.__awaiter (/app/node_modules/tslib/tslib.js:113:16)
2021-06-26T12:50:53.671168452Z at middleware (/app/build/middlewares/createContextMiddleware.js:12:47)
2021-06-26T12:50:53.671173216Z at execute (/app/node_modules/telegraf/lib/composer.js:457:23)
2021-06-26T12:50:53.671178188Z at /app/node_modules/telegraf/lib/composer.js:458:27
2021-06-26T12:50:53.671747182Z (node:1) 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: 2)
2021-06-26T12:50:53.671787878Z (node:1) [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.

This then gets the server in an unhealthy state and it becomes unable to reply to any other messages afterwards.

To Reproduce
Steps to reproduce the behavior:

  1. Trigger a kick member event
  2. See error

Expected behavior
It should ignore the kick member event or other non-reply events and keep the process healthy.

@armand1m armand1m added bug Something isn't working help wanted Extra attention is needed labels Jun 28, 2021
@armand1m
Copy link
Owner Author

armand1m commented Jul 4, 2021

in theory this got fixed in the last commit, where instead of checking if the reply is available at all, I just console.log it and cancel the event flow in case I can't.

I'm going to keep monitoring to see if this issue is going to happen again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant