From a210b4788c5138036429f99a31886ada52586444 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 be8f0d72..6149dfe7 100644 --- a/src/telegramPolling.js +++ b/src/telegramPolling.js @@ -103,7 +103,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 @@ -124,6 +124,21 @@ class TelegramBotPolling { }; return this.request('getUpdates', opts).then(() => { throw 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(() => {