From cb1c378c5a688eca7706860588fb8209715ab65b Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 21 Sep 2026 06:21:09 +0000 Subject: [PATCH] fix(server): close task event streams when the client only wants a replay Interrupted runs often have no done event, so a refresh replay would otherwise hold the SSE connection open. Co-authored-by: Cursor --- internal/server/task_run_handlers.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/server/task_run_handlers.go b/internal/server/task_run_handlers.go index 5bbb4b61..435616c2 100644 --- a/internal/server/task_run_handlers.go +++ b/internal/server/task_run_handlers.go @@ -502,6 +502,10 @@ func (s *Server) handleTaskRunEvents(w http.ResponseWriter, r *http.Request) { if err := writeStoredEvents(replay); err != nil { return } + // 刷新后只重放已落库事件,避免 interrupted 任务没有 done/error 时把连接挂住。 + if r.URL.Query().Get("replay_only") == "1" { + return + } for _, stored := range replay { if stored.Event.Type == stream.EventDone || stored.Event.Type == stream.EventError { return