discordrb icon indicating copy to clipboard operation
discordrb copied to clipboard

Remove extra attempted heartbeat after stopping Bot normally

Open kaine119 opened this issue 5 years ago • 1 comments

Summary

Changes the sequence of time delays in the heartbeat thread.

If the delay happens after checking the session, the session could be suspended while the thread is sleeping, causing us to try to heartbeat on a suspended session. Moving the sleep down sends the heartbeat right after the check.


Changed

  • Gateway's @heartbeat_thread: Moved the heartbeat_interval delay to after raising the heartbeat event, before checking if the session is suspended.

kaine119 avatar Jan 09 '21 15:01 kaine119

We need to do a few more things for this change. Ideally we would kill the heartbeat loop on disconnect, and allow it to restart on HELLO, so we also aren't trying to send a heartbeat without an active connection.

We also need to kill the thread that detects zombie connections, since that will continue to attempt to reconnect as well.

swarley avatar Jan 16 '21 23:01 swarley