Skip to content

Conversation

@Toricane
Copy link
Contributor

About

This pull request shows the 429 error properly.

I've been seeing lots of JSONDecodeErrors from mostly Replit users (there is a documented case of it happening with Heroku as well), which leads to a TypeError. The common "fix" given to them was just to do kill 1 in the shell with no additional information as to what happened and why.

When I looked further into the code, I saw that when Cloudflare ratelimits you, it returns an HTML page instead of JSON, causing the JSONDecodeError (because the library tries to JSONify the response immediately without any checks), which is typical for Replit users. The suggestion of kill 1 basically runs the code on a new server in Replit, sometimes with a new IP, so it temporarily works again.

Ideally, this error shouldn't occur at all because the library handles ratelimits awesomely, but when it does occur, it isn't handled properly.

This PR highlights that it is a 429 error instead of not handling the exception.

Checklist

  • The pre-commit code linter has been run over all edited files to ensure the code is linted.
  • I've ensured the change(s) work on 3.8.6 and higher.

I've made this pull request: (check all that apply)

  • For the documentation
  • To add a new feature
  • As a general enhancement
  • As a refactor of the library/the library's code
  • To fix an existing bug
  • To resolve #ISSUENUMBER

This is:

  • A breaking change

@Toricane Toricane added bug Something isn't working specific condition This happens on specific condition labels Oct 17, 2022
@Toricane Toricane requested a review from EepyElvyra October 17, 2022 02:26
@Toricane Toricane marked this pull request as draft October 17, 2022 05:27
@Toricane Toricane marked this pull request as ready for review October 18, 2022 00:52
@Toricane
Copy link
Contributor Author

@EdVraz ready for review

@Toricane Toricane enabled auto-merge (squash) November 4, 2022 01:22
Copy link
Contributor

@EepyElvyra EepyElvyra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm I think

@Toricane Toricane merged commit c50c8fb into interactions-py:unstable Nov 4, 2022
@Toricane Toricane deleted the fix-429-error-not-shown branch November 4, 2022 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working specific condition This happens on specific condition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants