fix(FR-2815): break BAITable resizable column infinite update loop#7267
Merged
Conversation
Contributor
Author
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has required the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR opts two hot paths into the React Compiler’s memoization by adding the 'use memo'; directive to a session form component and a resource-limit hook.
Changes:
- Added
'use memo';directive touseResourceLimitAndRemaininghook. - Added
'use memo';directive toResourceAllocationFormItemscomponent.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
react/src/hooks/useResourceLimitAndRemaining.tsx |
Adds 'use memo'; at the start of the hook body to enable React Compiler memoization for the hook’s returned values/closures. |
react/src/components/SessionFormItems/ResourceAllocationFormItems.tsx |
Adds 'use memo'; at the start of the component body to enable React Compiler memoization for this form section. |
Contributor
Coverage Report for react-coverage (./react)
File Coverage
|
||||||||||||||||||||||||||||||||||||||
512a7e8 to
6cb8b59
Compare
6cb8b59 to
768441c
Compare
768441c to
4cd2388
Compare
Contributor
Coverage Report for backend-ai-ui-coverage (./packages/backend.ai-ui)
File Coverage
|
||||||||||||||||||||||||||||||||||||||
38ce9ed to
601d2e1
Compare
601d2e1 to
e089638
Compare
Merge activity
|
…7267) Resolves #7248(FR-2815) ## Summary `/session/start` crashed with **"Maximum update depth exceeded"** on the 26.4.x release backend. The trigger surface was `VFolderTable` inside the Storage step Card while that Card was hidden (`display: none`). ## Root cause BAITable's `ResizableTitle` workaround for un-specified column widths self-loops when its measurement target has width 0: 1. The `useEffect` that measures the header cell has **no dependency array**, so it fires on every render. 2. When `width` prop is `undefined`, the effect calls `onResize(offsetWidth)`, which `setResizedColumnWidths` records. 3. The parent reads that value back via `resizedColumnWidths[key] || column.width`. Inside a hidden ancestor the measured value is `0`, and **`0 || undefined`** falls through to `undefined`. So the next render again has `width: undefined`. 4. `ResizableTitle` re-runs the effect, again measures `0`, again writes it. React hits its 50-update render limit and throws. Stack traces pointed at antd `EllipsisMeasure` because `BAIText` (in a sibling cell) was the last commit-target when the limit was hit; the actual setState cascade originates in BAITable's `ResizableTitle` path. ## Why it didn't manifest before - `resizable` default was `false` until recently; `ResizableTitle` was not used at all so the loop didn't exist. - After the default flipped to `true`, the loop is latent in any BAITable rendered inside a hidden ancestor with un-widthed columns. `/session/start` is the first surface to hit it because its step Cards stay mounted and toggle visibility with `display: none` (so the Storage VFolderTable mounts at width 0 on initial render). - Other endpoints don't crash because their VFolder responses have fewer rows / different column widths so the loop never accumulates beyond React's 50-update limit. ## Fix - Use `??` instead of `||` for the `resizedColumnWidths` fallback so a measured `0` is preserved and not coalesced back to `undefined`. - Skip the `onResize` self-call when `offsetWidth === 0`. A 0-width measurement is meaningless inside a hidden ancestor, and skipping it breaks the loop without affecting the visible-column code path. The default `resizable: true` is preserved; only the loop-prone branch is guarded. Other consumers of BAITable inherit the fix automatically. ## Verification - Relay: PASS - Lint: PASS - Format: PASS - TypeScript: pre-existing failures only on `main` (unrelated; tracked separately under FR-2816). ## Manual smoke test - Open `/session/start` against the 26.4.x release backend → page loads without the React update-depth crash. - Navigate through all 5 steps (`SessionType` → `Environment` → `Storage` → `Network` → `Review`) → form values persist; transitions work; Storage step's VFolderTable shows rows correctly. - Confirm column resize on visible BAITable instances (e.g., `/data` page) still works as before.
e089638 to
979d465
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Resolves #7248(FR-2815)
Summary
/session/startcrashed with "Maximum update depth exceeded" on the 26.4.x release backend. The trigger surface wasVFolderTableinside the Storage step Card while that Card was hidden (display: none).Root cause
BAITable's
ResizableTitleworkaround for un-specified column widths self-loops when its measurement target has width 0:useEffectthat measures the header cell has no dependency array, so it fires on every render.widthprop isundefined, the effect callsonResize(offsetWidth), whichsetResizedColumnWidthsrecords.resizedColumnWidths[key] || column.width. Inside a hidden ancestor the measured value is0, and0 || undefinedfalls through toundefined. So the next render again haswidth: undefined.ResizableTitlere-runs the effect, again measures0, again writes it. React hits its 50-update render limit and throws.Stack traces pointed at antd
EllipsisMeasurebecauseBAIText(in a sibling cell) was the last commit-target when the limit was hit; the actual setState cascade originates in BAITable'sResizableTitlepath.Why it didn't manifest before
resizabledefault wasfalseuntil recently;ResizableTitlewas not used at all so the loop didn't exist.true, the loop is latent in any BAITable rendered inside a hidden ancestor with un-widthed columns./session/startis the first surface to hit it because its step Cards stay mounted and toggle visibility withdisplay: none(so the Storage VFolderTable mounts at width 0 on initial render).Fix
??instead of||for theresizedColumnWidthsfallback so a measured0is preserved and not coalesced back toundefined.onResizeself-call whenoffsetWidth === 0. A 0-width measurement is meaningless inside a hidden ancestor, and skipping it breaks the loop without affecting the visible-column code path.The default
resizable: trueis preserved; only the loop-prone branch is guarded. Other consumers of BAITable inherit the fix automatically.Verification
main(unrelated; tracked separately under FR-2816).Manual smoke test
/session/startagainst the 26.4.x release backend → page loads without the React update-depth crash.SessionType→Environment→Storage→Network→Review) → form values persist; transitions work; Storage step's VFolderTable shows rows correctly./datapage) still works as before.