mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 17:30:16 +01:00
fix: Prevent memory leaks in useResumableSSE by clearing handler maps on stream completion and cleanup
This commit is contained in:
parent
1b2d3f30ef
commit
08052844cf
1 changed files with 5 additions and 0 deletions
|
|
@ -151,6 +151,8 @@ export default function useResumableSSE(
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
setShowStopButton(false);
|
setShowStopButton(false);
|
||||||
}
|
}
|
||||||
|
// Clear handler maps on stream completion to prevent memory leaks
|
||||||
|
clearStepMaps();
|
||||||
(startupConfig?.balance?.enabled ?? false) && balanceQuery.refetch();
|
(startupConfig?.balance?.enabled ?? false) && balanceQuery.refetch();
|
||||||
sse.close();
|
sse.close();
|
||||||
setStreamId(null);
|
setStreamId(null);
|
||||||
|
|
@ -369,6 +371,7 @@ export default function useResumableSSE(
|
||||||
contentHandler,
|
contentHandler,
|
||||||
resetContentHandler,
|
resetContentHandler,
|
||||||
syncStepMessage,
|
syncStepMessage,
|
||||||
|
clearStepMaps,
|
||||||
messageHandler,
|
messageHandler,
|
||||||
errorHandler,
|
errorHandler,
|
||||||
setIsSubmitting,
|
setIsSubmitting,
|
||||||
|
|
@ -476,6 +479,8 @@ export default function useResumableSSE(
|
||||||
sseRef.current.close();
|
sseRef.current.close();
|
||||||
sseRef.current = null;
|
sseRef.current = null;
|
||||||
}
|
}
|
||||||
|
// Clear handler maps to prevent memory leaks and stale state
|
||||||
|
clearStepMaps();
|
||||||
// Reset UI state on cleanup - useResumeOnLoad will restore if needed
|
// Reset UI state on cleanup - useResumeOnLoad will restore if needed
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
setShowStopButton(false);
|
setShowStopButton(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue