From 80bf91b50e1fb8115ecb07f9a34124a7b9a2eb57 Mon Sep 17 00:00:00 2001 From: GochoMugo Date: Wed, 1 Feb 2017 17:54:41 +0300 Subject: [PATCH] src/polling: Log failure to handle Offset Infinite Loop bug --- src/telegramPolling.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/telegramPolling.js b/src/telegramPolling.js index b4fe884e..8df5d1bb 100644 --- a/src/telegramPolling.js +++ b/src/telegramPolling.js @@ -111,7 +111,7 @@ class TelegramBotPolling { }) .catch(err => { debug('polling error: %s', err.message); - /** + /* * We need to mark the already-processed items * to avoid fetching them again once the application * is restarted, or moves to next polling interval @@ -129,6 +129,21 @@ class TelegramBotPolling { }; return this.bot.getUpdates(opts).then(() => { return this._error(err); + }).catch(requestErr => { + /* + * We have been unable to handle this error. + * We have to log this to stderr to ensure devops + * understands that they may receive already-processed items + * on app restart. + */ + /* eslint-disable no-console */ + const bugUrl = 'https://github.com/yagop/node-telegram-bot-api/issues/36#issuecomment-268532067'; + console.error('error: Internal handling of The Offset Infinite Loop failed'); + console.error(`error: This was due to error '${requestErr}'`); + console.error('error: You may receive already-processed updates on app restart'); + console.error(`error: Please see ${bugUrl} for more information`); + /* eslint-enable no-console */ + throw err; }); }) .finally(() => {