Bug Report
macOS Sierra 10.12.3[email protected][email protected]No warnings.
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)
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
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.
Most helpful comment
I believe we know what we are doing, so we can
return nullat src/telegramPolling.js#L107.I smell a PR here! :wink: