mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-30 18:53:30 +00:00
Gateway: Prevent heartbeat reconnecting twice
This commit is contained in:
parent
2f6ab0d451
commit
7b67a98405
|
@ -360,9 +360,15 @@ func (g *Gateway) start(ctx context.Context) error {
|
|||
g.waitGroup.Done() // mark so Close() can exit.
|
||||
wsutil.WSDebug("Event loop stopped with error:", err)
|
||||
|
||||
// Bail if there is no error or if the error is an explicit close, as
|
||||
// there might be an ongoing reconnection.
|
||||
if err == nil || errors.Is(err, wsutil.ErrWebsocketClosed) {
|
||||
return
|
||||
}
|
||||
|
||||
// Only attempt to reconnect if we have a session ID at all. We may not
|
||||
// have one if we haven't even connected successfully once.
|
||||
if err != nil && g.SessionID() != "" {
|
||||
if g.SessionID() != "" {
|
||||
g.ErrorLog(err)
|
||||
g.Reconnect()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue