From 12985ade6db6240bfdb56e73524919af505ee4f9 Mon Sep 17 00:00:00 2001 From: iris Date: Sun, 31 May 2026 21:31:57 +0200 Subject: [PATCH] fix(#726): handle broadcast Lagged + clear on SSE reconnect Distinguish RecvError::Lagged from Closed in the build-log stream loop: Lagged continues (next recv delivers the full accumulated delta via saved cursors), Closed returns (shutdown path). Clear pre.textContent and reset cursor lengths in es.onerror when readyState is CONNECTING so auto-reconnect doesn't double-append the replay from cursor=0. --- frontend/packages/dashboard/src/tabs.js | 8 +++++++- hive-c0re/src/dashboard.rs | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/packages/dashboard/src/tabs.js b/frontend/packages/dashboard/src/tabs.js index ca24ec8c..7afb27ba 100644 --- a/frontend/packages/dashboard/src/tabs.js +++ b/frontend/packages/dashboard/src/tabs.js @@ -1216,7 +1216,13 @@ window.marked = marked; } }; es.onerror = () => { - if (es.readyState === EventSource.CLOSED) { + if (es.readyState === EventSource.CONNECTING) { + // Auto-reconnect: clear accumulated content so the + // fresh stream from cursor=0 doesn't double-append. + pre.textContent = ''; + stdoutLen = 0; + stderrLen = 0; + } else if (es.readyState === EventSource.CLOSED) { detail._es = null; } }; diff --git a/hive-c0re/src/dashboard.rs b/hive-c0re/src/dashboard.rs index e43490e2..1e470a46 100644 --- a/hive-c0re/src/dashboard.rs +++ b/hive-c0re/src/dashboard.rs @@ -1789,7 +1789,8 @@ async fn get_build_log_stream( Err(_) => return, } } - Err(_) => return, // notification channel closed (shutdown) + Err(tokio::sync::broadcast::error::RecvError::Lagged(_)) => continue, + Err(tokio::sync::broadcast::error::RecvError::Closed) => return, } } });