Skip to content

stopPolling() doesn't cancel the polling connection #455

Description

@peoro

Bug Report

I have read:

I am using the latest version of the library.

Expected Behavior

After calling stopPolling no listener should be left waiting for polling-related events: if no other event handlers are active, Node's event loop should terminate.

Actual Behavior

A TLSSocket object starts listening on a socket when polling starts. stopPolling doesn't stop it.

This is because HTTPS requests to the Telegram server use the forever agent (src/telegram.js:230), and the agent is not cancelled by stopPolling (which calls this._polling.stop(): src/telegramPolling.js:57)

Steps to reproduce the Behavior

Run the following piece of code:

const TelegramBot = require('node-telegram-bot-api');
const bot = new TelegramBot(TOKEN, {polling:true});
bot.stopPolling();

This program never terminates as the polling request is still active.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions