jehy / telegram-test-api

Simple implimentation of telegram API which can be used for testing telegram bots
MIT License
98 stars 24 forks source link

Fix periodic cleanup #41

Closed mirlord closed 3 years ago

mirlord commented 3 years ago

Current master with a default config fails once it reaches the storeTimeout:

> telegram-test-api@2.4.5 start /home/vladimir/dev/telegram-test-api
> DEBUG=TelegramServer:* node --use_strict ./bin/start

  TelegramServer:server Telegram API server config: {"protocol":"http","host":"localhost","port":9000,"storage":"RAM","storeTimeout":60000} +0ms
  TelegramServer:server Telegram API server is up on port 9000 in development mode +11ms
  TelegramServer:storage clearing storage +0ms
/home/vladimir/dev/telegram-test-api/telegramServer.js:149
    debugStorage(`current userMessages storage: ${this.storage.userMessages.length}`);
                                                               ^

TypeError: Cannot read property 'userMessages' of undefined
    at Timeout.cleanUp [as _onTimeout] (/home/vladimir/dev/telegram-test-api/telegramServer.js:149:64)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
coveralls commented 3 years ago

Coverage Status

Coverage remained the same at 84.797% when pulling 2d61073791547aab498f23cad44e4e33c83f4e7f on mirlord:cleanup-npe into df2198b91ce8c8d57fb87d98ba5730740c250a20 on jehy:master.

jehy commented 3 years ago

Yup, thanks, good fix!