feat(irc): log connection errors (#1239)

* add logline for failed connection

* modify logging, change debug -> error

* don't surface "client called Quit" errors

* irc: don't retry Connect() while stopped

* fix issue number

* don't unlock until state-change complete

* Revert "don't unlock until state-change complete"

This reverts commit bf107db99bc2758b729a5995c63067f8fdf16aec.

---------

Co-authored-by: Shivaram Lingamneni <slingamn@cs.stanford.edu>
This commit is contained in:
Frederick Robinson 2023-11-18 06:44:46 -08:00 committed by GitHub
parent fef0da5711
commit 7cb2aaa8a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,10 @@ import (
"github.com/sasha-s/go-deadlock" "github.com/sasha-s/go-deadlock"
) )
var (
clientManuallyDisconnected = retry.Unrecoverable(errors.New("IRC client was manually disconnected"))
)
type channelHealth struct { type channelHealth struct {
m deadlock.RWMutex m deadlock.RWMutex
@ -219,7 +223,17 @@ func (h *Handler) Run() error {
func() error { func() error {
h.log.Debug().Msgf("connect attempt %d", connectAttempts) h.log.Debug().Msgf("connect attempt %d", connectAttempts)
// #1239: don't retry if the user manually disconnected with Stop()
h.m.RLock()
manuallyDisconnected := h.manuallyDisconnected
h.m.RUnlock()
if manuallyDisconnected {
return clientManuallyDisconnected
}
if err := h.client.Connect(); err != nil { if err := h.client.Connect(); err != nil {
h.log.Error().Err(err).Msg("client encountered connection error")
connectAttempts++ connectAttempts++
return err return err
} }