From 8332f0de2b6571e37cf40d7460e2a6f7a106b8ef Mon Sep 17 00:00:00 2001 From: yyh Date: Tue, 27 Jan 2026 01:23:08 +0800 Subject: [PATCH] fix(workflow): reinitialize mounted ref on effect setup for StrictMode In React StrictMode (dev mode), effects are run twice to help detect side effects. The cleanup-only pattern left isMountedRef as false after StrictMode's simulated unmount-remount cycle, causing stop/cancel operations to be skipped even when the component was mounted. Now the effect setup explicitly sets isMountedRef.current = true, ensuring correct behavior in both development and production. --- .../panel/debug-and-preview/hooks/use-chat-flow-control.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/app/components/workflow/panel/debug-and-preview/hooks/use-chat-flow-control.ts b/web/app/components/workflow/panel/debug-and-preview/hooks/use-chat-flow-control.ts index 21af491126..62c67fb65b 100644 --- a/web/app/components/workflow/panel/debug-and-preview/hooks/use-chat-flow-control.ts +++ b/web/app/components/workflow/panel/debug-and-preview/hooks/use-chat-flow-control.ts @@ -21,8 +21,11 @@ export function useChatFlowControl({ const invalidateRun = useStore(s => s.invalidateRun) const isMountedRef = useRef(true) - useEffect(() => () => { - isMountedRef.current = false + useEffect(() => { + isMountedRef.current = true + return () => { + isMountedRef.current = false + } }, []) const { handleNodeCancelRunningStatus } = useNodesInteractionsWithoutSync(isMountedRef)