From bdd69a1fb73b9e68c66354da1d5dac1a83de1cab Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Sat, 7 Feb 2026 18:11:04 +0100 Subject: [PATCH] fix(healthcheck): prevent race condition and fix #3096 (#3123) --- internal/healthcheck/checker.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/healthcheck/checker.go b/internal/healthcheck/checker.go index 39565c5f..71256852 100644 --- a/internal/healthcheck/checker.go +++ b/internal/healthcheck/checker.go @@ -106,14 +106,22 @@ func (c *Checker) Start(ctx context.Context) (runError <-chan error, err error) if err != nil { err = fmt.Errorf("small periodic check: %w", err) } - runErrorCh <- err + select { + case <-ctx.Done(): + continue + case runErrorCh <- err: + } smallCheckTimer.Reset(smallCheckPeriod) case <-fullCheckTimer.C: err := c.fullPeriodicCheck(ctx) if err != nil { err = fmt.Errorf("full periodic check: %w", err) } - runErrorCh <- err + select { + case <-ctx.Done(): + continue + case runErrorCh <- err: + } fullCheckTimer.Reset(fullCheckPeriod) } }