From 3b19054ead131c18f3d38e5a2193b91a55705741 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Fri, 7 Mar 2025 13:24:21 -0900 Subject: [PATCH] try fix --- web/server.go | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/web/server.go b/web/server.go index 2eef970..358fdcf 100644 --- a/web/server.go +++ b/web/server.go @@ -442,20 +442,22 @@ func (s *Server) handleEvents() http.HandlerFunc { }() // Keep connection open and send events as they arrive - for { - select { - case msg, ok := <-clientChan: - if !ok { + go func() { + for { + select { + case msg, ok := <-clientChan: + if !ok { + return + } + fmt.Fprintf(w, "%s\n\n", msg) + if flusher, ok := w.(http.Flusher); ok { + flusher.Flush() + } + case <-r.Context().Done(): return } - fmt.Fprintf(w, "%s\n\n", msg) - if flusher, ok := w.(http.Flusher); ok { - flusher.Flush() - } - case <-r.Context().Done(): - return } - } + }() } } @@ -503,20 +505,22 @@ func (s *Server) handleAdminEvents() http.HandlerFunc { }() // Keep connection open and send events as they arrive - for { - select { - case msg, ok := <-clientChan: - if !ok { + go func() { + for { + select { + case msg, ok := <-clientChan: + if !ok { + return + } + fmt.Fprintf(w, "%s\n\n", msg) + if flusher, ok := w.(http.Flusher); ok { + flusher.Flush() + } + case <-r.Context().Done(): return } - fmt.Fprintf(w, "%s\n\n", msg) - if flusher, ok := w.(http.Flusher); ok { - flusher.Flush() - } - case <-r.Context().Done(): - return } - } + }() } }