From 9c3ecc70381de15512353e0e2546ab3c323d4ba0 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Sat, 4 Apr 2026 18:34:10 +0200 Subject: [PATCH] fix(sse): send plain string body for subsequent SSE events http-kit's send! after the initial response expects a plain string, not a full response map with status/headers. Sending a response map was silently dropped, so SSE clients never received change notifications after the initial "connected" message. Verified working: toggling a todo in one tab updates the other tab within ~30ms via SSE. --- src/pocketbook/server.clj | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pocketbook/server.clj b/src/pocketbook/server.clj index ebd8a2e..5478266 100644 --- a/src/pocketbook/server.clj +++ b/src/pocketbook/server.clj @@ -66,15 +66,12 @@ (swap! sse-clients update group disj ch)))) (defn- sse-notify! - "Send an SSE event to all listeners of the given groups." + "Send an SSE event to all listeners of the given groups. + After the initial response, http-kit send! takes a plain string body." [groups] (doseq [group groups ch (get @sse-clients group)] - (http/send! ch {:status 200 - :headers {"Content-Type" "text/event-stream" - "Cache-Control" "no-cache"} - :body (str "data: " group "\n\n")} - false))) ;; false = don't close, keep streaming + (http/send! ch (str "data: " group "\n\n") false))) ;; --------------------------------------------------------------------------- ;; Handlers