Skip to content

Commit

Permalink
fix: handle improper 1000 closures by discord (#2632)
Browse files Browse the repository at this point in the history
* Handle improper 1000 closures by Discord

Signed-off-by: Quintenvw <[email protected]>

* style(pre-commit): auto fixes from pre-commit.com hooks

---------

Signed-off-by: Quintenvw <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Quintenvw and pre-commit-ci[bot] authored Oct 29, 2024
1 parent 9a6cbff commit e25ea6f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion discord/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,16 @@ def latency(self) -> float:

def _can_handle_close(self):
code = self._close_code or self.socket.close_code
return code not in (1000, 4004, 4010, 4011, 4012, 4013, 4014)
is_improper_close = self._close_code is None and self.socket.close_code == 1000
return is_improper_close or code not in (
1000,
4004,
4010,
4011,
4012,
4013,
4014,
)

async def poll_event(self):
"""Polls for a DISPATCH event and handles the general gateway loop.
Expand Down

0 comments on commit e25ea6f

Please sign in to comment.