From ce496d1caf019b9149079cd3fc362c39fd21ef2b Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Tue, 28 Apr 2026 23:22:48 -0400 Subject: [PATCH] fix(api): prevent browser from coalescing concurrent stream requests Add cache-busting query parameter to the stream fetch URL so each tab gets a unique request and the browser cannot reuse an in-flight response. Remove redundant Transfer-Encoding header that Go sets automatically. --- backend/internal/api/handlers.go | 1 - frontend/src/client.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/internal/api/handlers.go b/backend/internal/api/handlers.go index 2e2045c..7f9ae7c 100644 --- a/backend/internal/api/handlers.go +++ b/backend/internal/api/handlers.go @@ -435,7 +435,6 @@ func (a *API) GetChatStream(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/x-ndjson") w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Connection", "keep-alive") - w.Header().Set("Transfer-Encoding", "chunked") flushWriter := newFlushWriter(w) // Send Snapshot diff --git a/frontend/src/client.ts b/frontend/src/client.ts index 107456f..5049d2c 100644 --- a/frontend/src/client.ts +++ b/frontend/src/client.ts @@ -120,7 +120,7 @@ export async function streamChatUpdates( chatId: string, onChunk: (chunk: MessageChunk) => void, ) { - const response = await fetch(`/api/chats/${chatId}/stream`); + const response = await fetch(`/api/chats/${chatId}/stream?_t=${Date.now()}`); return streamMessage(response, onChunk); }