Skip to content

Commit

Permalink
fix: prevent event source from reconnecting after SSE close event (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhopperlowe authored Dec 2, 2024
1 parent e14ed55 commit f6cbd25
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ui/admin/app/components/chat/ChatContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,12 @@ function useMessageSource(threadId?: Nullish<string>) {

if (!threadId) return;

const source = ThreadsService.getThreadEventSource(threadId);

let replayComplete = false;
let replayMessages: ChatEvent[] = [];

const source = ThreadsService.getThreadEventSource(threadId);
source.addEventListener("close", source.close);

source.onmessage = (chunk) => {
const event = JSON.parse(chunk.data) as ChatEvent;

Expand Down

0 comments on commit f6cbd25

Please sign in to comment.