From eac001527cad05e39d8322376b4bafff3ee451ca Mon Sep 17 00:00:00 2001 From: Ramnique Singh <30795890+ramnique@users.noreply.github.com> Date: Fri, 22 Aug 2025 18:39:31 +0530 Subject: [PATCH] close eventsource on chat unmount --- .../[projectId]/playground/components/chat.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/rowboat/app/projects/[projectId]/playground/components/chat.tsx b/apps/rowboat/app/projects/[projectId]/playground/components/chat.tsx index e14229e0..5f634bdc 100644 --- a/apps/rowboat/app/projects/[projectId]/playground/components/chat.tsx +++ b/apps/rowboat/app/projects/[projectId]/playground/components/chat.tsx @@ -160,6 +160,16 @@ export function Chat({ setIsLastInteracted(true); } + // clean up event source on component unmount + useEffect(() => { + return () => { + if (eventSourceRef.current) { + eventSourceRef.current.close(); + eventSourceRef.current = null; + } + } + }, []); + useEffect(() => { const container = scrollContainerRef.current; if (!container) return;