Skip to content

Commit dd3a19b

Browse files
committed
address comments
1 parent ff4325f commit dd3a19b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pkg/manager/runnable_group.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,19 @@ func (r *runnableGroup) reconcile() {
245245

246246
// Start the runnable.
247247
if err := rn.Start(r.ctx); err != nil {
248-
// Send error with context awareness to prevent blocking during shutdown
249-
select {
250-
case r.errChan <- err:
251-
// Error sent successfully
252-
case <-r.ctx.Done():
253-
// Context cancelled (shutdown), drop error to prevent blocking forever
254-
// This prevents goroutine leaks when error drain go routine has exited after timeout
248+
// Check if we're in shutdown mode
249+
r.stop.RLock()
250+
isStopped := r.stopped
251+
r.stop.RUnlock()
252+
253+
if isStopped {
254+
// During shutdown, drop errors to prevent goroutine leaks
255255
if !errors.Is(err, context.Canceled) { // don't log context.Canceled errors as they are expected during shutdown
256256
r.logger.Info("error dropped during shutdown to prevent goroutine leak", "error", err)
257257
}
258+
} else {
259+
// During normal operation, always try to send errors (may block briefly)
260+
r.errChan <- err
258261
}
259262
}
260263
}(runnable)

0 commit comments

Comments
 (0)