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;