interactions-py / interactions.py

A highly extensible, easy to use, and feature complete bot framework for Discord
https://interactions-py.github.io/interactions.py/
MIT License
833 stars 185 forks source link

[BUG] Websocket Heartbeat Interval TypeError on reconnect #1651

Open Scrxtchy opened 5 months ago

Scrxtchy commented 5 months ago

Library Version

userapps @ 73c73fd516baa4036e57338432ec1d57e69df888

Describe the Bug

During a gateway reconnect event, the application crashed due to the either the d or heartbeat_interval values being not set, or the event payload somehow also being None

Steps to Reproduce

  1. Run app
  2. Wait for or force Reconnect
  3. receive invalid data?
  4. Crash

Expected Results

Library should either raise an error or handle it

Minimal Reproducible Code

No response

Traceback

POST::https://discord.com/api/v10/interactions/{clientid}/{token}/callback: 404
Ignoring exception in Autocomplete Callback for /ranking team - Option: SlashCommandOption(): HTTPException: 404|Not Found || Unknown interaction
Shard ID 0 | Traceback (most recent call last):
  File "/mnt/mpathaf/scratch/hidden/june/lib/python3.10/site-packages/interactions/api/gateway/state.py", line 110, in _ws_connect
    await self.gateway.run()
  File "/mnt/mpathaf/scratch/hidden/june/lib/python3.10/site-packages/interactions/api/gateway/gateway.py", line 171, in run
    await self.dispatch_opcode(data, op)
  File "/mnt/mpathaf/scratch/hidden/june/lib/python3.10/site-packages/interactions/api/gateway/gateway.py", line 194, in dispatch_opcode
    return await self.reconnect(resume=True, url=self.ws_resume_url)
  File "/mnt/mpathaf/scratch/hidden/june/lib/python3.10/site-packages/interactions/api/gateway/gateway.py", line 281, in reconnect
    await super().reconnect(resume=resume, code=code, url=url)
  File "/mnt/mpathaf/scratch/hidden/june/lib/python3.10/site-packages/interactions/api/gateway/websocket.py", line 262, in reconnect
    self.heartbeat_interval = hello["d"]["heartbeat_interval"] / 1000
TypeError: 'NoneType' object is not subscriptable

Checklist

Additional Information

No response

asyntx commented 4 months ago

In accordance with #1657 , please specify your Python version

Scrxtchy commented 4 months ago

Python 3.10.14

asyntx commented 4 months ago

Please set the library logging level to logging.DEBUG and follow up with a full log leading up to the traceback error so we can further look into this.