From c5b62d41ae7fb6d79bf013443bb16628314a09c3 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Wed, 17 Jun 2026 21:28:31 +0800 Subject: [PATCH] fix: set StateReady after temporary accept error retry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Accept() returns a transient error, the service enters StateFailed, sleeps for the retry delay, then loops back to Accept(). Previously the state stayed StateFailed until the next successful Accept() — which could take arbitrarily long for idle services, making status observers see a stale 'error' even though the service has already reconnected and is ready. Now set StateReady (and clear lastError) immediately after the retry sleep. Accept will block until the next connection, but the state correctly reflects that the service is functional. --- service/service.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/service/service.go b/service/service.go index 20be9aff..73407ef7 100644 --- a/service/service.go +++ b/service/service.go @@ -227,6 +227,14 @@ func (s *defaultService) Serve() error { log.Warnf("accept: %v, retrying in %v", e, tempDelay) time.Sleep(tempDelay) + + // Transition back to Ready so status observers see the + // recovered service immediately, instead of waiting for + // the next successful Accept (which may block arbitrarily). + if s.status.State() == StateFailed { + s.setState(StateReady) + s.status.setLastError(nil) + } continue } s.setState(StateClosed)