From 1cd840a1c3f11173d2e7bbb4c0e9a87625e1b523 Mon Sep 17 00:00:00 2001 From: shiftinv <8530778+shiftinv@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:23:37 +0100 Subject: [PATCH 1/2] fix: attempt resume on websocket closure with `close_code = 1000` in edge cases (#1241) --- changelog/1241.bugfix.rst | 1 + disnake/gateway.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 changelog/1241.bugfix.rst diff --git a/changelog/1241.bugfix.rst b/changelog/1241.bugfix.rst new file mode 100644 index 0000000000..0765a61e23 --- /dev/null +++ b/changelog/1241.bugfix.rst @@ -0,0 +1 @@ +Attempt to handle abrupt websocket closures on ``aiohttp >= 3.9.0`` and ``python < 3.11.0`` gracefully. diff --git a/disnake/gateway.py b/disnake/gateway.py index b42414b924..ef54d5580b 100644 --- a/disnake/gateway.py +++ b/disnake/gateway.py @@ -687,6 +687,21 @@ def latency(self) -> float: return float("inf") if heartbeat is None else heartbeat.latency def _can_handle_close(self) -> bool: + # bandaid fix for https://github.com/aio-libs/aiohttp/issues/8138 + # tl;dr: on aiohttp >= 3.9.0 and python < 3.11.0, aiohttp returns close code 1000 (OK) + # on abrupt connection loss, not 1006 (ABNORMAL_CLOSURE) like one would expect, ultimately + # due to faulty ssl lifecycle handling in cpython. + # If we end up in a situation where the close code is 1000 but we didn't + # initiate the closure (i.e. `self._close_code` isn't set), assume this has happened and + # try to reconnect. + if self._close_code is None and self.socket.close_code == 1000: + _log.info( + "Websocket remote in shard ID %s closed with %s. Assuming the connection dropped.", + self.shard_id, + self.socket.close_code, + ) + return True # consider this a reconnectable close code + code = self._close_code or self.socket.close_code return code not in (1000, 4004, 4010, 4011, 4012, 4013, 4014) From fbfc814ff77e2c6d9178817b3323a7dfbb75a36f Mon Sep 17 00:00:00 2001 From: shiftinv Date: Thu, 14 Nov 2024 20:38:24 +0100 Subject: [PATCH 2/2] docs: add v2.9.3 changelog to latest docs --- changelog/1180.doc.rst | 1 - changelog/1228.feature.rst | 1 - changelog/1228.misc.rst | 1 - changelog/1241.bugfix.rst | 1 - docs/whats_new.rst | 27 +++++++++++++++++++++++++++ 5 files changed, 27 insertions(+), 4 deletions(-) delete mode 100644 changelog/1180.doc.rst delete mode 100644 changelog/1228.feature.rst delete mode 100644 changelog/1228.misc.rst delete mode 100644 changelog/1241.bugfix.rst diff --git a/changelog/1180.doc.rst b/changelog/1180.doc.rst deleted file mode 100644 index 1ef07bb612..0000000000 --- a/changelog/1180.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Adding some clarifying documentation around the type of :attr:`AuditLogEntry.extra` when the action is :attr:`~AuditLogAction.overwrite_create`. diff --git a/changelog/1228.feature.rst b/changelog/1228.feature.rst deleted file mode 100644 index 5457283ab9..0000000000 --- a/changelog/1228.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Add support for ``aead_xchacha20_poly1305_rtpsize`` encryption mode for voice connections, and remove deprecated ``xsalsa20_poly1305*`` modes. diff --git a/changelog/1228.misc.rst b/changelog/1228.misc.rst deleted file mode 100644 index 505effd2b8..0000000000 --- a/changelog/1228.misc.rst +++ /dev/null @@ -1 +0,0 @@ -Raise PyNaCl version requirement to ``v1.5.0``. diff --git a/changelog/1241.bugfix.rst b/changelog/1241.bugfix.rst deleted file mode 100644 index 0765a61e23..0000000000 --- a/changelog/1241.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Attempt to handle abrupt websocket closures on ``aiohttp >= 3.9.0`` and ``python < 3.11.0`` gracefully. diff --git a/docs/whats_new.rst b/docs/whats_new.rst index 2293c918d7..4564e88651 100644 --- a/docs/whats_new.rst +++ b/docs/whats_new.rst @@ -17,6 +17,33 @@ in specific versions. Please see :ref:`version_guarantees` for more information. .. towncrier release notes start +.. _vp2p9p3: + +v2.9.3 +------ + +This is a maintainance release with several minor bugfixes. +Notably, this includes support for a newer voice encryption mode; +all modes supported in previous versions are scheduled to be :ddocs:`discontinued ` on 18th November 2024, +and voice connections using the builtin :class:`VoiceClient` will fail to connect. + +New Features +~~~~~~~~~~~~ +- Add support for ``aead_xchacha20_poly1305_rtpsize`` encryption mode for voice connections, and remove deprecated ``xsalsa20_poly1305*`` modes. (:issue:`1228`) + +Bug Fixes +~~~~~~~~~ +- Attempt to handle abrupt websocket closures on ``aiohttp >= 3.9.0`` and ``python < 3.11.0`` gracefully. (:issue:`1241`) + +Documentation +~~~~~~~~~~~~~ +- Adding some clarifying documentation around the type of :attr:`AuditLogEntry.extra` when the action is :attr:`~AuditLogAction.overwrite_create`. (:issue:`1180`) + +Miscellaneous +~~~~~~~~~~~~~ +- Raise PyNaCl version requirement to ``v1.5.0``. (:issue:`1228`) + + .. _vp2p9p2: v2.9.2