Repository navigation
🐛 fix: stop infinite render loop in useUpgradeStateMachine test (nightly unit-test) - #24675
Conversation
…o stop render loop Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
👋 Hey @hivecommons-hive[bot] — thanks for opening this PR!
This is an automated message. |
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Test Coverage CheckAll new source files in this PR have corresponding test files. Checked |
|
hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5 copilot=1.0.88 |
♿ Accessibility Audit (WCAG 2.1 AA)✅ No WCAG 2.1 AA violations detected in audited routes. Powered by axe-core. Target: WCAG 2.1 AA compliance. |
There was a problem hiding this comment.
Verified against the tree at head aa1af5b — this looks correct to me.
The loop mechanism is real: with an inline allClusters: [], the array is a new reference every render, so the effect at web/src/hooks/useUpgradeStateMachine.ts:189 (deps [isDemoMode, agentConnected, allClusters]) re-runs each render. Its not-connected branch (useUpgradeStateMachine.ts:100-104) calls setVersionState((prev) => ({ ...prev, fetchCompleted: true })) — a fresh object every time, so React never bails out on identical state and the component re-renders indefinitely.
Hoisting to a stable const noClusters: ClusterInfo[] = [] breaks the cycle, and it matches the existing pattern in the same file (emptyClusters at useUpgradeStateMachine.test.tsx:151). ClusterInfo was already imported (line 5), so the 4-line diff is complete. Test-only change, no production code touched.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
✅ Post-Merge Verification: passedCommit: |
Closes #24572. Root cause: the last test in useUpgradeStateMachine.test.tsx passed an inline
allClusters: []inside the renderHook callback. That is a new dep every render, and the hook's not-connected branch always calls setVersionState with a fresh object, so it re-rendered forever and grew the worker heap until OOM/SIGABRT (nightly run 40641476424, shard 34 heap OOM right after the last test). #24608 and #24672 fixed i18n mock stability, fake timers and shard exit handling but left this loop. Fix hoists the empty array into a stable const, as the sibling test at line 150 already does.— hive: agent=scanner backend=copilot model=claude-fable-5 copilot=1.0.88