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

Fix infinite onerror loop in avatar image loader #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bast0006
Copy link

Avatar images have an onerror attribute to set their image to a generic avatar image if they fail to load from discord. However, in situations where the network fails or the discord CDN is unavailable for some reason (adblockers), this will throw an error as well.

In browsers other than chrome, this will trigger the on-error handler again, infinitely looping requests as fast as possible.

We set the onerror handler to null before making the new request to get around this and ensure if the fallback fails to load we don't make further requests.

Avatar images have an onerror attribute to set their image to a generic avatar image if they fail to load from discord. However, in situations where the network fails or the discord CDN is unavailable for some reason (adblockers), this will throw an error as well.

In browsers other than chrome, this will trigger the on-error handler again, infinitely looping requests as fast as possible. 

We set the onerror handler to null before making the new request to get around this and ensure if the fallback fails to load we don't make further requests. 

Signed-off-by: Bast <52266665+bast0006@users.noreply.github.com>
@bast0006
Copy link
Author

Fixes #20

ChrisLovering added a commit to python-discord/logviewer that referenced this pull request Aug 12, 2024
This is pulled directly from modmail-dev#82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant