Fixes stream end event never being called

For writable streams, like `http.ClientRequest`, there is no `end` event, only `finish`. Thus, `req.end` was never called and never sending a response.

This resulted in a nasty bug for WebHook users that basically rendered the library useless because if Telegram doesn't receive a response from the bot server, it will continue to queue and send requests until it does, or until 24 hours have passed.
experimental
icdevin 10 years ago
parent 2498e44ed7
commit 20d174de0b
  1. 2
      src/telegramWebHook.js

@ -71,7 +71,7 @@ class TelegramBotWebHook {
} else if (req.method === 'POST') {
req
.pipe(bl(this._parseBody))
.on('end', () => res.end('OK'));
.on('finish', () => res.end('OK'));
} else {
// Authorized but not a POST
debug('WebHook request isn\'t a POST');

Loading…
Cancel
Save