Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot gets Very Sad when Discord API endpoint throws HTTP/5xx error #8

Open
dopeghoti opened this issue May 9, 2021 · 4 comments
Open
Labels
bug Something isn't working

Comments

@dopeghoti
Copy link
Owner

Stack trace from stderr follows:

Unhandled exception in internal background task 'find_messages'.
Traceback (most recent call last):
  File "/home/ghoti/.local/lib/python3.7/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
    await self.coro(*args, **kwargs)
  File "./bot.py", line 240, in find_messages
    @bot.command( name='list', help='Report a list of everyone in the Database' )
  File "/home/ghoti/.local/lib/python3.7/site-packages/discord/iterators.py", line 308, in flatten
    data = await self._retrieve_messages(self.retrieve)
  File "/home/ghoti/.local/lib/python3.7/site-packages/discord/iterators.py", line 348, in _retrieve_messages_before_strategy
    data = await self.logs_from(self.channel.id, retrieve, before=before)
  File "/home/ghoti/.local/lib/python3.7/site-packages/discord/http.py", line 265, in request
    raise DiscordServerError(r, data)
discord.errors.DiscordServerError: 502 Bad Gateway (error code: 0): <!DOCTYPE html>

Looks like it may be an upstream issue in discord.py but I might just had to do some exception handling.

@dopeghoti dopeghoti added the bug Something isn't working label May 9, 2021
@dopeghoti
Copy link
Owner Author

I may have a fix for this; it is in a separate branch while I test before I pull it into the mainline.

@CrystalSpore
Copy link

As an FYI, the LGBTea Cafe team is now also using the mentioned Dev branch. We'll let you know if we come across any issues 👍

@dopeghoti dopeghoti changed the title Bot gets Very Sad when Discord API endpoint throws HTTL/5xx error Bot gets Very Sad when Discord API endpoint throws HTTP/5xx error Apr 2, 2022
@dopeghoti
Copy link
Owner Author

Appreciate it. I have found that while it does help it does not fix the issue because that one location isn't the only one where Discord can throw an Exception at me, so I'll be updating that dev branch soon with more extensive exception handling to hopefully put a pin in this issue once and for all. Also I really love the name of your Team!

@CrystalSpore
Copy link

After almost a month of uptime the bot finally died again, so definitely the current version on the other branch is a great improvement.

I'm including the crash error below, in hops that that will provide some insight into the issue:

This is running on an Ubuntu 20.04.4 LTS bare metal server, using an AMD Ryzen 3 2200G.

Unhandled exception in internal background task 'find_messages'.
Traceback (most recent call last):
  File "./bot.py", line 241, in find_messages
    msgs = await MonitorChannel.history().flatten()
  File "/usr/local/lib/python3.8/dist-packages/discord/iterators.py", line 308, in flatten
    data = await self._retrieve_messages(self.retrieve)
  File "/usr/local/lib/python3.8/dist-packages/discord/iterators.py", line 348, in _retrieve_messages_before_strategy
    data = await self.logs_from(self.channel.id, retrieve, before=before)
  File "/usr/local/lib/python3.8/dist-packages/discord/http.py", line 192, in request
    async with self.__session.request(method, url, **kwargs) as r:
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/client.py", line 559, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/client_reqrep.py", line 913, in start
    self._continue = None
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/helpers.py", line 721, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/tasks/__init__.py", line 101, in _loop
    await self.coro(*args, **kwargs)
  File "./bot.py", line 242, in find_messages
    except DiscordServerError:
NameError: name 'DiscordServerError' is not defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants