Closed sylvainmetayer closed 6 years ago
Sorry for late answer. Fixed it in version 1.00, but please beware that server needs much time (about 4 seconds) to stop (that seems like express's issue). You can check updated example for this.
@sylvainmetayer I investigated large timeout matter a bit further - it is not even express's problem, that's a nodejs problem - it does not stop http server if there are keep alive connections (and telegram bot uses keep alive connections): https://github.com/nodejs/node-v0.x-archive/issues/9066
Pretty funny to see that bug from 0.x versions is still present in node 9.... I will try to find some workaround.
@jehy Thanks for the explanation ! I'll give it a try tomorrow or wednesday and I'll come back to you
Fixed it in version 1.0.1 : )
I've updated to 1.0.1 but it seems that I'm still having the issue.
Here is how I tried to stop the server but I keep having an "EFATAL : Error: connect ECONNREFUSED 127.0.0.1:9000" polling error. Is it related to your last changes ? sylvainmetayer/Telegram_Bot@fde0974fed2400cba0c93bbac1fdc135d0299e64
Telegram bot client continues polling and that causes errors. You should add telegramBot.stopPolling()
to your after
block like this:
after(function (done) {
telegramBot.stopPolling();
// Because server.close() doesn't work and freeze CI
if (process.env.CIRCLECI != undefined) {
process.exit();
}
server.stop();
done();
})
By the way, server.stop();
returns promise, so it's better to use it like this (mocha becomes much prettier when using promises instead of callbacks):
after(function (done) {
telegramBot.stopPolling();
// Because server.close() doesn't work and freeze CI
if (process.env.CIRCLECI != undefined) {
process.exit();
}
return server.stop();
})
Great, it is now fixed ! Thanks !
Hello,
I'm developping a Telegram Bot for a school project and need a way to test it.
But I've got an issue when running tests, the server doesn't seems to stop. All tests are correctly executed, but the close promise isn't resolved.
The last output I can have is the "Stopping server..." but I never enter here (https://github.com/jehy/telegram-test-api/blob/master/src/telegramServer.js#L159).
Is this a known bug or am I using your package the wrong way ?
You can find below a example of my test file.
Thank you in advance for your reply !