fix(utils): bound Mermaid ASCII pathfinder#5295
Open
roboomp wants to merge 1 commit into
Open
Conversation
- Added bounded A* routing extents plus an expansion backstop so unreachable attachment points return null instead of searching the unbounded quadrant. - Covered the reported declaration-order graph and an enclosed destination attachment point. - Documented the Mermaid ASCII routing fix in the utils changelog. Fixes #5293
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.
Repro
The provided four-node Mermaid flowchart reproduced the hang with
timeout 5s bun .wt/repro-mermaid-ascii.ts: before the fix the harness produced no output and exited124, showingrenderMermaidAsciiSafe()did not return within the bounded run.Cause
packages/utils/src/vendor/mermaid-ascii/ascii/pathfinder.ts#getPathsearched every free coordinate in the non-negative quadrant and only returnednullafter the priority queue emptied. Whenpackages/utils/src/vendor/mermaid-ascii/ascii/edge-routing.ts#determinePathasked for an unreachable attachment point, the queue could never exhaust, so the existing direct fallback path was never reached.Fix
getPath().nullinstead of growing unbounded state.Verification
Ran
timeout 5s bun .wt/repro-mermaid-ascii.tsafter the fix; it returned in about 8 ms with output length419. Ranbun test packages/utils/test/mermaid-ascii.test.tswith 3 passing tests. Ranbun run checkinpackages/utilssuccessfully. Fixes #5293