Open
Description
Summary
Tracebacks in my logs
Reproduction Steps
Just be connected for a while
Code
Expected Results
No TypeError.
Actual Results
Traceback (most recent call last):
File "/venv/lib/python3.11/site-packages/discord/client.py", line 959, in connect
await self.ws.poll_event()
File "/venv/lib/python3.11/site-packages/discord/gateway.py", line 646, in poll_event
msg, flags = await asyncio.wait_for(self.socket.recv(), timeout=self._max_heartbeat_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/tasks.py", line 489, in wait_for
return fut.result()
^^^^^^^^^^^^
File "/venv/lib/python3.11/site-packages/curl_cffi/requests/websockets.py", line 621, in recv
chunk, frame = await self.recv_fragment(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.11/site-packages/curl_cffi/requests/websockets.py", line 585, in recv_fragment
self._unpack_close_frame(chunk)
File "/venv/lib/python3.11/site-packages/curl_cffi/requests/websockets.py", line 142, in _unpack_close_frame
if code < 3000 and (code not in WsCloseCode or code == 1005):
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 742, in __contains__
raise TypeError(
TypeError: unsupported operand type(s) for 'in': 'int' and 'EnumType'
System Information
- Python v3.11.12-final
- discord.py-self v2.1.0-beta
- discord.py-self metadata: v2.1.0b5102+g9262ca74
- discord-protos v0.0.2
- curl_cffi v0.10.0 (curl vlibcurl/8.7.0-DEV BoringSSL zlib/1.3 brotli/1.1.0 zstd/1.5.6 nghttp2/1.63.0 impersonating chrome131)
- aiohttp v3.11.16
- system info: Linux 6.1.0-32-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.129-1 (2025-03-06)
Checklist
- I have confirmed I am using unmodified discord.py-self and not the upstream discord.py.
- I am using a user token (and it isn't visible in the code).
- I have searched the open issues for duplicates.
- I have searched closed issues for resolved duplicates.
- I have confirmed the development version doesn't resolve the issue.
- I have shared the entire traceback.
Additional Information
A couple hours laters, it crashes with
ERROR:discord.gateway:An error occurred while stopping the gateway. Ignoring.
Traceback (most recent call last):
File "/venv/lib/python3.11/site-packages/discord/gateway.py", line 172, in run
await self.ws.close(4000)
File "/venv/lib/python3.11/site-packages/discord/gateway.py", line 864, in close
await self.socket.close(code, reason)
File "/venv/lib/python3.11/site-packages/curl_cffi/requests/websockets.py", line 730, in close
await self.send(msg, CurlWsFlag.CLOSE)
File "/venv/lib/python3.11/site-packages/curl_cffi/requests/websockets.py", line 667, in send
raise WebSocketClosed("WebSocket is closed")
curl_cffi.requests.websockets.WebSocketClosed: WebSocket is closed
Maybe it's related?