File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments