node-telegram-bot-api: Unhandled rejection Error: 502
Expected Behavior
today I opened my server error logs and i got tons (like 2 per second) of these errors:
7/12/2017, 1:38:41 PM - P.12854 - Unhandled rejection Error: 502 <html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.10.0</center>
</body>
</html>
at /home/ubuntu/Licode_v3/node_modules/node-telegram-bot-api/lib/telegramPolling.js:133:17
at tryCatcher (/home/ubuntu/Licode_v3/node_modules/request-promise/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/home/ubuntu/Licode_v3/node_modules/request-promise/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/home/ubuntu/Licode_v3/node_modules/request-promise/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromises (/home/ubuntu/Licode_v3/node_modules/request-promise/node_modules/bluebird/js/main/promise.js:700:14)
at Async._drainQueue (/home/ubuntu/Licode_v3/node_modules/request-promise/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/home/ubuntu/Licode_v3/node_modules/request-promise/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/home/ubuntu/Licode_v3/node_modules/request-promise/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
7/12/2017, 1:39:01 PM - P.12854 - Unhandled rejection TimeoutError: operation timed out
at afterTimeout (/home/ubuntu/Licode_v3/node_modules/request-promise/node_modules/bluebird/js/main/timers.js:16:15)
at Timeout.timeoutTimeout (/home/ubuntu/Licode_v3/node_modules/request-promise/node_modules/bluebird/js/main/timers.js:59:9)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
in my code I wrote ` // error handler (avoid spam in console)
telegram.on('polling_error', function(error) {});
telegram.on('webhook_error', function(error) {});
`
to prevent my log to get flooded but they didn’t caught these errors.
Is there any way to catch these errors? Probably the telegram servers were down and the bot tried to poll them.
thanks guys!!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 19
Commits related to this issue
- src: Improve default error logging of `polling_error`, `webhook_error` References: * BR: https://github.com/yagop/node-telegram-bot-api/issues/377 — committed to yagop/node-telegram-bot-api by GochoMugo 7 years ago
- doc/help: Add link to bug '502 Bad Gateway' References: * BR '502 Bad Gateway': https://github.com/yagop/node-telegram-bot-api/issues/377 — committed to yagop/node-telegram-bot-api by GochoMugo 7 years ago
- src: Improve default error logging of `polling_error`, `webhook_error` References: * BR: https://github.com/yagop/node-telegram-bot-api/issues/377 — committed to fullstackbusiness1128/node-telegram-bot-api by fullstackbusiness1128 7 years ago
- doc/help: Add link to bug '502 Bad Gateway' References: * BR '502 Bad Gateway': https://github.com/yagop/node-telegram-bot-api/issues/377 — committed to fullstackbusiness1128/node-telegram-bot-api by fullstackbusiness1128 7 years ago
I have the same problem.
Unhandled rejection Error: EPARSE: Error parsing Telegram response: <html>
<head><title>500 Internal Server Error</title></head>
<body bgcolor="white">
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx/1.12.2</center>
</body>
</html>
I was also getting it and i’m catching and suppressing it now.
nice catch @sedhuait, will implement that!
same here, the error should be treated differently by default otherwise it just ruins the server logs.
Maybe have a default condition for 502 Bad Gateway and don’t log so many lines, only say
“Telegram reported error 502 Bad Gateway”