Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion spark-ui/src/components/SqlFlow/SqlLayoutService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,12 @@ function getLayoutedElementsWithStages(
});

// Step 4: Run dagre layout
dagre.layout(g);
try {
dagre.layout(g);
} catch (e) {
console.warn("Compound dagre layout failed, falling back to simple layout", e);
return getLayoutedElements(flowNodes, flowEdges, cacheKey + "-fallback");
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback layout is cached under cacheKey + "-fallback", but getLayoutedElementsWithStages (and SqlElementsToLayout) look up layoutCache using the original cacheKey. If dagre compound layout keeps failing for a given graph, this will re-run the failing layout and emit console.warn on every call (performance + log spam) instead of reusing the fallback.

Consider caching the fallback result under the original cacheKey (e.g., compute fallback once, layoutCache.set(cacheKey, fallbackResult), then return it), and/or avoid the -fallback suffix so subsequent calls immediately reuse the fallback without retrying the broken compound layout.

Suggested change
return getLayoutedElements(flowNodes, flowEdges, cacheKey + "-fallback");
return getLayoutedElements(flowNodes, flowEdges, cacheKey);

Copilot uses AI. Check for mistakes.
}

// Step 5: Extract positions and build result nodes
const allNodes: Node[] = [];
Expand Down
Loading