Bug: useDaemonLifecycle retry timeout mutates store after unmount
Summary
app/src/hooks/useDaemonLifecycle.ts — the scheduleRetry setTimeout callback calls setIsRecovering, incrementConnectionAttempts, and resetConnectionAttempts without checking isMountedRef.current first. These mutate external Zustand-like store state on an unmounted component.
Location
app/src/hooks/useDaemonLifecycle.ts — retry useEffect and retryTimeoutRef
Impact
Low — Store mutations after unmount. Can cause React warnings and stale state.
Suggested Fix
Add if (!isMountedRef.current) return; at the top of the setTimeout body in scheduleRetry, before any store mutations.
I checked the current main branch, and scheduleRetry already has if (!isMountedRef.current) return; at the start of the retry timeout callback, before setIsRecovering, incrementConnectionAttempts, and resetConnectionAttempts.
It looks like the suggested minimal fix is already present. Is the remaining concern about the async case where the component unmounts while daemonHealth.startDaemon() is awaiting, so store updates after the await should also be guarded?
I rechecked current origin/main and the minimal timeout-body issue described here appears to be fixed.
Evidence in app/src/hooks/useDaemonLifecycle.ts:
scheduleRetryreturns early if!isMountedRef.currentbefore scheduling work.- The retry timeout callback also starts with
if (!isMountedRef.current) return;beforesetIsRecovering,incrementConnectionAttempts, orresetConnectionAttempts. - The surrounding async paths also have mounted checks before later state updates.
So the issue as written looks stale/resolved. If there is still a concern, I think it should be narrowed to a separate async-after-await path rather than the original retry timeout mutation.
Confirmed: scheduleRetry on current main already guards with if (!isMountedRef.current) return; before store mutations. Closing as already resolved — thanks @Yong-yuan-X and @honor2030 for verifying.