-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stopPolling() doesn't cancel the polling connection #455
Comments
I can not seem to reproduce this bug. Which Node.js version are you using? |
I'm using node 8.8.1 on some machines and 9.2.0 on others. I just tried again to run the snippet I provided and noticed something weird: the behaviour changes depending on the bot. Could you try reproducing this bug using the token of a newly created bot? I cannot use the bot I was using when I created this issue (since a program is already polling on it and I cannot stop it now), but the snippet was definitely taking longer than 10 seconds to terminate with that bot. |
I thought I was hitting this bug too, but giving it a better look it may help to provide cancel: true as object property. eg:
Just for anyone running into this. |
@arenddeboer did this but still getting an error when restarting the bot
|
I have this problem yet even when calling |
I have been experiencing this issue too - I found that by setting the bot._polling._abort flag to true just after calling bot.stopPolling(), it stopped the execution as expected. Looks like this flag is only being set if the options.cancel property is not set - thus it cancels the promise, but never stops execution. Perhaps the flag could be set just after (or before) the timer is cleared? |
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 callsthis._polling.stop()
: src/telegramPolling.js:57)Steps to reproduce the Behavior
Run the following piece of code:
This program never terminates as the polling request is still active.
The text was updated successfully, but these errors were encountered: