mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
fix(chat): add abort mechanism for in-flight requests on unmount
This commit is contained in:
parent
ea58415f88
commit
45b0751826
@ -209,6 +209,19 @@ export const useChat = (
|
||||
cb?.()
|
||||
}, [handleStop])
|
||||
|
||||
const abortInflightRequests = useCallback(() => {
|
||||
conversationMessagesAbortControllerRef.current?.abort()
|
||||
suggestedQuestionsAbortControllerRef.current?.abort()
|
||||
workflowEventsAbortControllerRef.current?.abort()
|
||||
}, [])
|
||||
|
||||
// Abort all in-flight fetch/SSE requests when the consumer unmounts
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
abortInflightRequests()
|
||||
}
|
||||
}, [abortInflightRequests])
|
||||
|
||||
const createAudioPlayerManager = useCallback(() => {
|
||||
let ttsUrl = ''
|
||||
let ttsIsPublic = false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user