fix(Table): guard rowExpansion tree walks against cyclic data#4070
Open
AKnassa wants to merge 2 commits into
Open
fix(Table): guard rowExpansion tree walks against cyclic data#4070AKnassa wants to merge 2 commits into
AKnassa wants to merge 2 commits into
Conversation
Cyclic or self-referential row data crashed useTableRowExpansionState with a stack overflow: all three tree walks (depthMap, flattened data, allExpandableKeys) recursed without ancestor tracking. Track the ancestor-key path in a Set and skip the cyclic edge, keeping first-encountered depth semantics. The allExpandableKeys walk crashed even with nothing expanded, since it recurses unconditionally. Fixes facebook#3971 Claude-Session: https://claude.ai/code/session_01P9qSoGWZPPp9pUNNRUSwkM
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis ReportNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | View full report |
…ard (facebook#3971) The cycle tests couldn't tell the prescribed ancestor-path guard from a global visited-set (which would silently drop a shared child under its second expanded parent on acyclic DAG data). Replace the redundant first-depth test with a DAG pin that fails on the visited-set variant, and retitle the once-each claims to what the assertions actually prove (termination).
AKnassa
marked this pull request as ready for review
July 19, 2026 02:04
AKnassa
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
July 19, 2026 02:04
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.
What this does
Stops the Table's row-expansion feature from crashing when the row data accidentally contains a loop (a row that ends up being its own ancestor).
Why
With cyclic data, the three internal tree walks recursed forever and crashed with a stack overflow — one of them even with nothing expanded. This is the cycle-guard follow-up humbertovirtudes prescribed in #3971, and the fix pattern mirrors the guarded tree walks already reviewed in #3789.
What changed
main(lint-staged applies it on commit) — safe to skip in review.How to see it
pnpm exec vitest run packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.test.tsx— 13/13 pass (the 3 cyclic ones crash with RangeError before the fix; the DAG test fails if the guard is degraded to a visited-set). Full core suite green.Fixes #3971