fix(15): prevent infinite loop in chat history fetch
The useEffect condition allowed fetching when fetchStatus was 'failed', causing infinite retry loops when the API returned an error. Changed condition from: fetchStatus !== 'loading' && fetchStatus !== 'succeeded' To: fetchStatus === 'idle' This ensures we only fetch once per channel on initial load, and don't retry automatically on failure. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
5df60ad6cf
commit
fce74152f8
|
|
@ -127,10 +127,13 @@ const JKChatMessageList = () => {
|
|||
|
||||
/**
|
||||
* Fetch chat history when channel becomes active
|
||||
* Only fetches if we haven't fetched yet for this channel
|
||||
* Only fetches once per channel (when status is 'idle')
|
||||
* Does NOT retry on failure to avoid infinite loops
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (activeChannel && fetchStatus !== 'loading' && fetchStatus !== 'succeeded') {
|
||||
// Only fetch when status is 'idle' (initial state)
|
||||
// This prevents infinite loops on API failure ('failed' status)
|
||||
if (activeChannel && fetchStatus === 'idle') {
|
||||
// For session chat, activeChannel is the sessionId
|
||||
// Pass sessionId so the thunk knows to fetch 'session' channel type
|
||||
dispatch(fetchChatHistory({
|
||||
|
|
|
|||
Loading…
Reference in New Issue