5310 / discord-bot-castform

A Discord bot that forecasts weather for Pokémon GO
26 stars 10 forks source link

Bot stop sending weather after error #9

Closed cyphercris closed 3 years ago

cyphercris commented 4 years ago

After error (api error?) bot stop working. Its possible to handle it and try renew the connection? https://pastebin.com/x5iukFx1

kamieniarz commented 4 years ago

Same issue here. I have to check from time to time if bot works - if not simple pm2 restart helps. I have this issue since I started using this bot and it happens every few days :(

5310 commented 4 years ago

I've only ever had the bot give up running while on rate limited (free) platforms like Glitch or Repl.it I ran it locally for a couple of days and didn't have it stop at any point.

Just to be sure, does the bot process hang completely, or is it that the AccuWeather API key runs out of its limit and silently fails?

kamieniarz commented 3 years ago

I had this error few days ago and cause of it specific area just stoped working. This error appeared at the same time for few keys so after all half of my areas stopped working till I noticed that today...

FetchError: invalid json response body at https://dataservice.accuweather.com/forecasts/v1/hourly/12hour/265958?apikey=MYKEY&details=true&metric=true reason: Unexpected token < in JSON at position 0
    at /home/user/discord-bot-castform/node_modules/node-fetch/lib/index.js:272:32
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  type: 'invalid-json'
}

Could that be fixed? I'm fine if one hour could be skipped due to error (or maybe retried?) but due to this error errored area won't be checked untill I restart bot 😫

5310 commented 3 years ago

(Somehow this issue keeps updating exactly when I'm out of station every time.)

I still haven't been able to make the bot crash yet, but if it's really some invalid pull from the AW API that's causing this it should definitely handle that exception.

Will see to it.

5310 commented 3 years ago

Exceptions while querying the API now handled with c5e9586. The bot won't get interrupted by them anymore.

Bonus, sensible logs for when a free API key runs out of quota! :raised_hands: