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 committed by Yago
parent cc3c206765
commit d6ef1f9d97
  1. 2
      src/telegramWebHook.js

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

Loading…
Cancel
Save