From 138746a4d6bcc5aec4e569c033f1357d3696dead Mon Sep 17 00:00:00 2001 From: Arif Dogan Date: Thu, 2 Jul 2026 13:59:03 +0200 Subject: [PATCH] fix: subscribe before the SSE snapshot so no add is missed (cherry picked from commit 0decbbdf0ce63663f933e94e09b7ae77b051d922) --- internal/dashboard/handler.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/dashboard/handler.go b/internal/dashboard/handler.go index 378cae4..939380c 100644 --- a/internal/dashboard/handler.go +++ b/internal/dashboard/handler.go @@ -193,20 +193,21 @@ func (h *Handler) handleSSE(w http.ResponseWriter, r *http.Request) { return true } - initial := h.store.GetAll() - if !writeEvent("snapshot", initial) { - return - } - // When the store is notifying (the default via Wrap), new entries are // pushed as they arrive; the ticker degrades to a heartbeat and a - // safety-net resync. + // safety-net resync. Subscribe before taking the snapshot so an Add in + // between is never silently missed — it just triggers one no-op flush. var notify <-chan struct{} if ns, ok := h.store.(*store.NotifyingStore); ok { ch, cancel := ns.Subscribe() defer cancel() notify = ch } + + initial := h.store.GetAll() + if !writeEvent("snapshot", initial) { + return + } tick := 15 * time.Second if notify == nil { tick = 2 * time.Second