samliew / se-electionbot

A Stack Exchange/Stack Overflow election chatbot written in Node.js to handle FAQs in an election chat room
MIT License
7 stars 6 forks source link

Return a dedicated error page on invalid election data #152

Open Oaphi opened 2 years ago

Oaphi commented 2 years ago

Currently, if the election data ends up invalid, depending on the occurrence of the check, the server is either not started up at all (if the failure happens early or crashes with a 500 on subsequent connects if the rescraper lead to an invalid election state. Latest to date downtime of the bot resulted from Stack Exchange breaking access to nomination pages - we want to avoid crashing if that happens as we can still serve some useful info in the meantime and periodically rescrape to ensure we are up and running as soon as the issue is fixed.

Already working on, documenting to keep track of the updates.

There are two sub-issues that need to be solved as part of this issue:

  1. The server is started way after Election#validate method is called, and the latter exits early
  2. The ScheduledAnnouncement#rescrape method ends up breaking the bot if the election state is invalid
Oaphi commented 2 years ago

Sub-issue 1: the server is now started much earlier, but still insufficiently early to be independent of election scraping:

https://github.com/samliew/se-electionbot/blob/eb304faf8e14bf52504e58728674d6c3a78b4d43/src/bot/index.js#L487

Oaphi commented 2 years ago

Sub-issue 2: should be fixed as election state can no longer break the bot due to internal try..catch blocks:

https://github.com/samliew/se-electionbot/blob/eb304faf8e14bf52504e58728674d6c3a78b4d43/src/bot/rescraper.js#L74