Commit 512a7e8
committed
fix(FR-2815): add 'use memo' to ResourceAllocationFormItems and useResourceLimitAndRemaining
Resolves #7248(FR-2815)
Hypothesis: /session/start throws 'Maximum update depth exceeded' on backend
rc2 (10.122.10.97) but not on main (10.122.10.107). The most plausible root
cause is an unstable-identity feedback loop in ResourceAllocationFormItems:
acceleratorSlotsInRG is built via _.omitBy on every render, feeding
supportedAcceleratorTypesInRGByImage (useMemo) which becomes the dep of an
effect that calls form.setFieldsValue when length === 0. Each setFieldsValue
renders, recomputes acceleratorSlotsInRG with new identity, fires the effect
again. useResourceLimitAndRemaining has the same identity-instability
amplifying through resourceLimits and allocatablePresetNames.
Why only on rc2: the rc2 server response likely trips the length === 0 branch
on every render (different image accelerator metadata); on main the branch is
not taken so the instability is harmless.
Fix: add 'use memo' to both files per .claude/rules/react-compiler-memoization.md.
The React Compiler (annotation mode) then memoizes the derived values based on
their actual inputs, breaking the feedback loop.
Verification: Relay/Lint/Format PASS. TypeScript: pre-existing failures only.
Needs verification on the test server.1 parent 00572ee commit 512a7e8
2 files changed
Lines changed: 2 additions & 0 deletions
File tree
- react/src
- components/SessionFormItems
- hooks
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
0 commit comments