fix(api): prevent browser from coalescing concurrent stream requests
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user