close eventsource on chat unmount

This commit is contained in:
Ramnique Singh 2025-08-22 18:39:31 +05:30
parent 2c3016f143
commit eac001527c

View file

@ -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;