The-Heeler-House / bot-bilby

Bot Bilby is a general Discord bot designed for The Heeler House.
MIT License
1 stars 2 forks source link

Race condition in LinkedMessageRemove event #39

Open CloudburstSys opened 2 months ago

CloudburstSys commented 2 months ago

Bilby will sometimes crash with the following stack trace:

UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<_Collection>".

This means a Promise is being rejected with a Collection as the "reason". Which can happen in Discord.js with certain methods.

CloudburstSys commented 2 months ago

The crash is indicative of a race condition present in LinkedMessageRemoveEvent caused by waiting for another bot to log the message deletion before notifying of the linked message deletion.

There are 2 possible fixes that I want opinions on:

  1. Continue relying on the 3rd party bot for deletion logs and just say that we couldn't find the deletion log if the collector times out
  2. Write our own log that we can guarantee will be present no matter what.
CloudburstSys commented 2 months ago

@sudoker0 @jalenluorion I'd like your opinions on how to proceed.