fix(merman): avoid infinite loop in side parallel transitions with equal endpoints - #48898
Open
marwanvx wants to merge 1 commit into
Open
fix(merman): avoid infinite loop in side parallel transitions with equal endpoints#48898marwanvx wants to merge 1 commit into
marwanvx wants to merge 1 commit into
Conversation
…ual endpoints When states in different composite parents share the same row, routing them through side-parallel transitions causes an infinite loop in addSideParallelTransition because startY === endY and the vertical stepping loop never reaches its termination condition. 1. Guard the vertical stepping loop in addSideParallelTransition so it is skipped when startY === endY. 2. Route cross-composite transitions between states on the same horizontal row via bottom-parallel rails instead of side-parallel. 3. Require from.centerY !== to.centerY in sideParallelTargetApproach before selecting side approach to avoid horizontal collisions. 4. Add unit and rendering regression tests in packages/merman. Fixes anomalyco#48573
Author
|
Linked issue: #48573 ( |
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
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.
Issue for this PR
Closes #48573
Type of change
What does this PR do?
When rendering nested Mermaid state diagrams where transitions connect states across composite boundaries that share the same horizontal row,
addSideParallelTransitionentered an infinite loop becausestartY === endY, causing unbounded cell allocation and an out-of-memory crash.This fix:
addSideParallelTransitionwithif (startY !== endY)to prevent infinite loop loops on equal endpoints.from.centerY !== to.centerYinsideParallelTargetApproachbefore picking a side target approach to prevent horizontal line collisions across target states.packages/merman.How did you verify your code works?
cd packages/merman && bun test src/state/routing.test.ts(31 pass, 0 fail)cd packages/merman && bun test -t "nested composite states sharing horizontal rows" src/state/diagram.test.ts(1 pass, 0 fail)cd packages/merman && bun run typecheck(0 errors)Screenshots / recordings
N/A
Checklist