Node-telegram-bot-api: Warning: a promise was created in a handler, but was not returned from it

Created on 5 Feb 2017  路  5Comments  路  Source: yagop/node-telegram-bot-api

Bug Report

Expected behavior

No warnings.

Actual behavior

When try to send a message, receive the following warning:

(node:91915) Warning: a promise was created in a handler at /Users/preco/Workspace/repos/telegram-bot/node_modules/node-telegram-bot-api/src/telegramPolling.js:102:17 but was not returned from it, see http://goo.gl/rRqMUw
    at new Promise (/Users/preco/Workspace/repos/telegram-bot/node_modules/bluebird/js/release/promise.js:77:14)

Steps to reproduce the Behavior

import TelegramBot from 'node-telegram-bot-api';

const bot = new TelegramBot(BOT_TOKEN, {polling: true});

bot.onText(/\/start/, ({chat: {id: chatId}}) => {
  bot.sendMessage(chatId, 'foobar');
});

with NODE_ENV=development environment variable

bug

Most helpful comment

If you know what you're doing and don't want to silence all warnings, you can create runaway promises without causing this warning by returning e.g. null:

http://bluebirdjs.com/docs/warning-explanations.html#warning-a-promise-was-created-in-a-handler-but-was-not-returned-from-it

I believe we know what we are doing, so we can return null at src/telegramPolling.js#L107.

I smell a PR here! :wink:

All 5 comments

This issue seems to be related to request-promise module.

https://github.com/petkaantonov/bluebird/blob/master/docs/docs/warning-explanations.md#warning-a-promise-was-created-in-a-handler-but-was-not-returned-from-it

I have debug above issue, I could find this warning caused on https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js#L155.

If you know what you're doing and don't want to silence all warnings, you can create runaway promises without causing this warning by returning e.g. null:

http://bluebirdjs.com/docs/warning-explanations.html#warning-a-promise-was-created-in-a-handler-but-was-not-returned-from-it

I believe we know what we are doing, so we can return null at src/telegramPolling.js#L107.

I smell a PR here! :wink:

Just pushed a fix for this in commit 3221d647ccdbcc58562faceabf94ee4c6dae6966. Please try it out and let us know of the results.

@GochoMugo Yea! It looks like fine now.

Fixed in v0.27.0.

Thanks @preco21 for your time and effort in fixing this bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mbrammer picture mbrammer  路  3Comments

lenny76 picture lenny76  路  3Comments

Kasra-S picture Kasra-S  路  3Comments

saeedhei picture saeedhei  路  4Comments

sidelux picture sidelux  路  3Comments