diff --git a/coderd/notifications/manager.go b/coderd/notifications/manager.go index 1a2c418a014bb..11588a09fb797 100644 --- a/coderd/notifications/manager.go +++ b/coderd/notifications/manager.go @@ -135,6 +135,8 @@ func (m *Manager) WithHandlers(reg map[database.NotificationMethod]Handler) { m.handlers = reg } +var ErrManagerAlreadyClosed = xerrors.New("manager already closed") + // Run initiates the control loop in the background, which spawns a given number of notifier goroutines. // Manager requires system-level permissions to interact with the store. // Run is only intended to be run once. @@ -146,7 +148,11 @@ func (m *Manager) Run(ctx context.Context) { go func() { err := m.loop(ctx) if err != nil { - m.log.Error(ctx, "notification manager stopped with error", slog.Error(err)) + if xerrors.Is(err, ErrManagerAlreadyClosed) { + m.log.Warn(ctx, "notification manager stopped with error", slog.Error(err)) + } else { + m.log.Error(ctx, "notification manager stopped with error", slog.Error(err)) + } } }() }) @@ -163,7 +169,7 @@ func (m *Manager) loop(ctx context.Context) error { m.mu.Lock() if m.closed { m.mu.Unlock() - return xerrors.New("manager already closed") + return ErrManagerAlreadyClosed } var eg errgroup.Group