Skip to content

fix: remove error log when notification manager is already closed #18264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions coderd/notifications/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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))
}
}
}()
})
Expand All @@ -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
Expand Down
Loading