fix(deploy): resolve infinite re-render in DeployControl - #41
Conversation
The `?? []` fallback in the deployments selector created a new array
reference on every render, causing Zustand to detect a state change and
trigger an infinite update loop ("Maximum update depth exceeded").
Replace with a module-level stable empty array constant, matching the
pattern already used for EMPTY_LOG and EMPTY_STATS in preview-pane.tsx.
|
Heads-up: PR #33 is already open against the same You and @cszhouwei may want to compare approaches; the maintainer team will decide which one lands. Sharing this so neither effort gets wasted. |
mrcfps
left a comment
There was a problem hiding this comment.
@jidechao Reviewed the DeployControl selector fix and the new EMPTY_DEPLOYMENTS fallback; this matches the stable selector pattern already used for EMPTY_LOG and EMPTY_STATS, so the changed range looks correct for stopping the render loop when a task has no deployments. Thanks for jumping on this bugfix so quickly 🙌
|
Adding one more coordination note: PR #42 is now also open against this same The maintainer team will choose which focused fix lands; noting the overlap so everyone has the latest picture. |
|
Superseded by #33 (squash-merged). Same fix landed via @cszhouwei's PR with the cleanest implementation (readonly module-scope constant). Thanks for the contribution! |
Summary
[]fallback in thedeploymentsZustand selector inDeployControlEMPTY_DEPLOYMENTS), matching the existing pattern used forEMPTY_LOGandEMPTY_STATSinpreview-pane.tsxRoot Cause
useStore((s) => selectActiveTask(s)?.deployments ?? [])creates a new[]reference on every render. Zustand detects the reference change, re-renders the component, which creates another new[], causing an infinite loop.Test plan
pnpm devand open the app