Chat2DB Edition
Chat2DB Community
Chat2DB Version
5.3.0
Deployment
Web
Operating System
macOS
Operating System Version
12
Database and Version
No response
Problem Summary
In chatQuestionTemplate, a mount-only useEffect calls queryExamplePrompt, which awaits chatService.queryChatExamplePrompt({}) and then calls setExamplePromptList(res) with no mounted/cancelled guard. If the component unmounts before the promise resolves, setState fires on an unmounted component.
Steps to Reproduce
- Open the chat question-template view.
- Unmount before the example-prompt fetch resolves (e.g. navigate away quickly).
- Observe a React unmounted-setState warning.
Expected Behavior
Guard the result with a mounted flag (e.g. let mounted = true in the mount effect, false in cleanup, check before setState), mirroring the NotificationNav pattern.
Actual Behavior
pages/main/chat/chatQuestionTemplate/index.tsx:17-26:
useEffect(() => {
queryExamplePrompt();
}, []);
const queryExamplePrompt = async () => {
const res = await chatService.queryChatExamplePrompt({});
if (res) {
setExamplePromptList(res);
}
};
Logs
Screenshots or Additional Context
N/A
Impact
Limited or cosmetic impact
Workaround
N/A
Submission Checklist
Chat2DB Edition
Chat2DB Community
Chat2DB Version
5.3.0
Deployment
Web
Operating System
macOS
Operating System Version
12
Database and Version
No response
Problem Summary
In
chatQuestionTemplate, a mount-onlyuseEffectcallsqueryExamplePrompt, whichawaitschatService.queryChatExamplePrompt({})and then callssetExamplePromptList(res)with no mounted/cancelled guard. If the component unmounts before the promise resolves,setStatefires on an unmounted component.Steps to Reproduce
Expected Behavior
Guard the result with a mounted flag (e.g.
let mounted = truein the mount effect,falsein cleanup, check beforesetState), mirroring the NotificationNav pattern.Actual Behavior
pages/main/chat/chatQuestionTemplate/index.tsx:17-26:Logs
Screenshots or Additional Context
N/A
Impact
Limited or cosmetic impact
Workaround
N/A
Submission Checklist