From 448893290d2a4d32b043884b773c56cf5d8becb3 Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Sat, 1 Aug 2026 13:34:30 +0800 Subject: [PATCH] fix(main): ensure safe closure of homeClient to prevent idle connections --- cmd/server/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 5df6342cf..0d8cdecec 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -284,7 +284,11 @@ func main() { homeCfg.DisableClusterDiscovery = true } homeClient = home.New(homeCfg) - defer homeClient.Close() + defer func() { + if homeClient != nil { + homeClient.Close() + } + }() ctxHomeConfig, cancelHomeConfig := context.WithTimeout(context.Background(), 30*time.Second) raw, errGetConfig := homeClient.GetConfig(ctxHomeConfig) @@ -622,6 +626,12 @@ func main() { return } } + if homeClient != nil { + // The bootstrap client is not owned by the runtime service. Close it after + // the final startup report so it cannot retain an idle RESP connection. + homeClient.Close() + homeClient = nil + } if pluginHost.HasTriggeredCommandLineFlags() { if exitCode, handled := pluginHost.ExecuteCommandLine(context.Background(), os.Args[0], os.Args[1:], configFilePath, flag.CommandLine); handled { if exitCode != 0 {