Contains a rather subtle bug. When this.parse is called, it will fire events. If any event handler throws an error, it will bubble up until it is caught either on line 110, line 122, or line 169.
If the error makes it all the way to 169 (it was thrown by a message or other listener) then the code assumes that a network error has occurred and, after waiting 30 seconds, tries to fetch messages from message 0 - when the server was started.
30 seconds later, messages will be fetched from the start, reparsed (likely causing spam), and the error will probably be thrown again, resulting in the same behavior.
AC:
[ ] add tests for each listener type throwing and the chat watcher simply ignoring the issue
[ ] add error handling for listeners that throw in a helper function which parse will use to dispatch events
[ ] log any errors thrown by listener functions with console.error
The code here: https://github.com/Blockheads-Messagebot/MessageBot/blob/master/src/chatWatcher.ts#L163-L174
Contains a rather subtle bug. When
this.parse
is called, it will fire events. If any event handler throws an error, it will bubble up until it is caught either on line 110, line 122, or line 169.If the error makes it all the way to 169 (it was thrown by a message or other listener) then the code assumes that a network error has occurred and, after waiting 30 seconds, tries to fetch messages from message 0 - when the server was started.
30 seconds later, messages will be fetched from the start, reparsed (likely causing spam), and the error will probably be thrown again, resulting in the same behavior.
AC:
parse
will use to dispatch eventsconsole.error
To reproduce:
Add a command:
Type
/fail
in the chat. No error will be logged and the bot will enter an infinite loop.