From 69fcab717cbe140a796146ca8d9ab5039a81d713 Mon Sep 17 00:00:00 2001 From: Hiren Kangad Date: Thu, 12 Mar 2026 20:17:20 +0530 Subject: [PATCH] fix(review): add recursion depth guard to group child resolution Prevents stack overflow from corrupted data with circular group references. --- frontend/src/canvas/reviewTargeting.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/canvas/reviewTargeting.ts b/frontend/src/canvas/reviewTargeting.ts index 8903bd4..83f3d59 100644 --- a/frontend/src/canvas/reviewTargeting.ts +++ b/frontend/src/canvas/reviewTargeting.ts @@ -41,7 +41,9 @@ function resolveGroupChild( group: SceneItem, worldX: number, worldY: number, + depth = 0, ): SceneItem | null { + if (depth > 10) return null; // Guard against circular group references const groupData = group.data as GroupObject; // Collect children that exist in the scene, sorted front-to-back (highest z first) @@ -59,7 +61,7 @@ function resolveGroupChild( // Nested group — recurse if (child.data.type === 'group') { - const nested = resolveGroupChild(scene, child, worldX, worldY); + const nested = resolveGroupChild(scene, child, worldX, worldY, depth + 1); if (nested) return nested; // No valid child inside nested group under this point — skip continue;