Add error handling for dagre layout and fallback to simple layout#55
Add error handling for dagre layout and fallback to simple layout#55cxzl25 wants to merge 1 commit intodataflint:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves resilience of the SQL flow graph layout by handling Dagre compound-layout failures and falling back to a simpler layout, preventing the UI from hard-failing on known Dagre compound graph edge cases.
Changes:
- Wrap compound
dagre.layout(g)intry/catchinside the staged (compound) layout path. - On failure, log a warning and fall back to the existing “simple” (non-compound) Dagre layout.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| dagre.layout(g); | ||
| } catch (e) { | ||
| console.warn("Compound dagre layout failed, falling back to simple layout", e); | ||
| return getLayoutedElements(flowNodes, flowEdges, cacheKey + "-fallback"); |
There was a problem hiding this comment.
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.
| return getLayoutedElements(flowNodes, flowEdges, cacheKey + "-fallback"); | |
| return getLayoutedElements(flowNodes, flowEdges, cacheKey); |
|
@cxzl25 where and how this change was required? I'd like to understand better the scenario. Thanks |

Uh oh!
There was an error while loading. Please reload this page.