Skip to content

Commit e25ea6f

Browse files
fix: handle improper 1000 closures by discord (#2632)
* 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>
1 parent 9a6cbff commit e25ea6f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

discord/gateway.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,16 @@ def latency(self) -> float:
587587

588588
def _can_handle_close(self):
589589
code = self._close_code or self.socket.close_code
590-
return code not in (1000, 4004, 4010, 4011, 4012, 4013, 4014)
590+
is_improper_close = self._close_code is None and self.socket.close_code == 1000
591+
return is_improper_close or code not in (
592+
1000,
593+
4004,
594+
4010,
595+
4011,
596+
4012,
597+
4013,
598+
4014,
599+
)
591600

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

0 commit comments

Comments
 (0)