From b8aae421fab40e3aad64c6c955cc04454228a4b0 Mon Sep 17 00:00:00 2001 From: Yifu Yu Date: Wed, 5 Aug 2026 05:25:36 +0800 Subject: [PATCH] Try to cleanup clients even if the stream is dead. Hope Gemini 3.5 Pro is not lying to me :P --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 254338f..a1fd40a 100644 --- a/main.go +++ b/main.go @@ -221,6 +221,11 @@ func clientHandler(w http.ResponseWriter, r *http.Request) { ch := NewClientChannel(name) defer ch.Close() for { + select { + case <-r.Context().Done(): + fmt.Printf("Connection to client %s closed. Cleanup the channel.\n", remote) + default: + } chunk := <-ch.Data _, err := w.Write(chunk) if err != nil {